I’ve been looking for different ways to send keystrokes, mouse movements and clicks to GUI applications. Under Windows, this is straight forward with AutoIt. The BASIC-like language allows you to read files, start applications, send keystrokes move the mouse etc. A nice feature is to wait for certain dialogs, for example:
; wait for tightvnc window
WinWaitActive("New TightVNC Connection")
; send hostname and port number
Send($hostname & ":" & $displaynumber)
This makes sure that the keystrokes actually end up in the right window. Mouse coordinates can be specified relative to the application window. Using these features allows you to write ‘reasonably’ robust code. But don’t expect your AutoIt script to run flawlessly on other PC’s. There are a lot of dependencies, like dialogs that look different in another version. Internationalization might cause the window title to read “Nieuwe TightVNC Verbinding” (Dutch) and the above code snippet will fail. Even user preferences like font sizes, window themes and screen resolution might result in unexpected behavior.
Anyway, it’s just fun to figure out which sequences to send to an application and let it process a batch of documents!
Ok, this works pretty nice under windows. But what about my favorite platform?
(more…)