HomePage | SiteMap | Refresh| EditPage| RenamePage| WikiHelp| LogIn

MacrosPythonAccessibility

Macros

Windows “macro programs” like Macro Scheduler and Macro Express allow users to record sequences of keyboard and mouse events for later playback. Judging from the number of them on the market I’m guessing they are a pretty popular way to automate recurring actions.

Macros and Python

It occurs to me that we could implement such a thing using pyAA and make it much more powerful and useful. A Python module on top of pyAA that makes it easy to automate GUI‘s would be a really great tool for automating otherwise unscriptable applications. For example, I’d like to convert my midi music files to “Impulse Tracker” files using ModPlug Tracker. Now this app might be scriptable but I don’t really want to learn their scripting language. I also don’t want to repeat the multi-step GUI interaction required for dozens of midi files in Hark the Sound.

What I’d like is a simple way to grab the appropriate GUI handles so that I can run the program from a Python script. Conceptually the script is quite simple. Something like:

for filename in os.listdir():
    basename, ext = os.path.splitext(filename)
    prog.Open(filename)
    prog.SaveAs(filename + '.it')

Assuming I had some tools to make it easy to define how to activate the Open and SaveAs actions in this particular program I’m automating. Pete’s clever naming scheme from Clique might work here, or it might work a bit like the wxPython XML resource editor “xrced:http://xrced.sourceforge.net/” in reverse. You start up a program, hook a watcher to it, and then use the GUI to accomplish tasks. The result is some XML that describes the events required for each. Now in your script you have an easy way to hook to the XML to invoke the actions you recorded earlier.

Macros, Python, and Accessibility

Given such a tool, improving the accessibility of common applications might be much simpler. For example I hear that iTunes has a really terrible interface. Adding a few keyboard-based accellerators to it could be quite easy and realy helpful.