[Tutor] Developing Macro: Is it possible in Python?

Alan Gauld alan.gauld at btinternet.com
Sun Aug 3 10:06:52 CEST 2008

"Federo" <federo at email.si> wrote

> Is it possible to do macro with Python?

Macro means different things in different context.

> Macro should be able to click on given x,y screen
> location (one click, double click), drag scroll bar up / down etc..

It seems that you are referring to simulating user actions.

The answer then is yes its possible but not trivial.
You can use the low level Windows API to send messages
to windows simulating mouse clicks etc. But it will usually require
monitoring the messages first using a program like Windows Spy.
The result is extremely fragile in that any change in the windows
environment can render your code useless.

> Is there any other way beside macro to control windows
> based application?

If it supports COM then you can use COM objects to
manipulate things directly. The winall package has support
for COM or you can use the API directly via ctypes.

I confess I tend to use VBScript for this kind of thing,
IMHO it plays with Windows much more simply than Python.

Alan G. 

More information about the Tutor mailing list