Automating DevStudio made easy (was: Developing Visual Studio add-ins in Python?)

Gerson Kurz gerson.kurz at t-online.de
Fri Jul 13 10:15:43 EDT 2001


On Thu, 12 Jul 2001 01:03:21 GMT, "Russ Shotts" <rashotts at mn.rr.com>
wrote:
>Has anyone used Python to create a Visual Studio add-in?  I need to perform
>some fairly complex processing, and their VBScript macros just cannot handle
>the task.
ARGH! Python has beat me again - it is *a lot* easier than I thought
:) There is no need to write an add-in in order to automate MS
DevStudio from Python.

Try this code:
------
import win32com.client

app = win32com.client.Dispatch('MSDev.Application')
wnd = app.ActiveWindow
if wnd.Type == 'Text':
    print wnd.Selection
app = None
------
It obviously prints the currently selected text :)

The object model is desribed in the MSDN at this path:

Visual Studio 6.0 Documentation\
Visual C++ Documentation\
Using Visual C++\
Visual C++ Users Guide\
Automating Tasks in Visual Studio\
Developer Studio Objects\
Reference: Developer Studio Objects.

On my machine (W2K SP2) it works when I have one instance of DevStudio
open, I can access the objects in that instance from the fine
Pythonwin. What more can you wish for :) 




More information about the Python-list mailing list