In order to define a contextual action for map windows, you need to put your Python script in your Python directory under a directory called Contextual_Map_Window.
Go to Tools->Options->Environment->Python Scripts (or Tools->Options->Python->Scripts in INTViewer 5.2) and click "Refresh from Disk". Your script should be listed automatically.
You will now be able to execute this script from the contextual menu of the map window:
This script will export the contents of the window to a .kmz file that can be opened in Google Earth.
This script is attached to the bottom of this article.
Below is a screenshot of the output file in Google Earth.