Automating MS Developer Studio

This example comments out a selection in Microsoft Developer Studio.

import win32com.client

# This script comments out the currently selected text block
app = win32com.client.Dispatch('MSDev.Application')
wnd = app.ActiveWindow
if wnd.Type == 'Text':

    # Get current selection
    select = str(wnd.Selection)

    # comment out    
    s = map(lambda x:'//'+x,select.split('\r\n'))

    # Replace current selection by new textbuffer    
    wnd.Selection = '\r\n'.join(s)

app = None

Leave a Reply

Your email address will not be published. Required fields are marked *