Or for a more "hackable" experience on Windows, you can do what (I expect) AutoHotKey does, and send window messages to apps to trigger "key press" and "mouse down at X coords".
By analogy it's as is there's a single stable interface to the GUI layers in apps mediated by the OS, instead of poking at X APIs.