Controlling the Mac OSX GUI via Python?

Christian Gollwitzer auriocus at gmx.de
Sat Jul 2 02:30:26 EDT 2016


Am 02.07.16 um 05:16 schrieb Lawrence D’Oliveiro:
> On Friday, July 1, 2016 at 4:59:11 PM UTC+12, Christian Gollwitzer wrote:
>> Yes, simulating mouse clicks with
>> fixed coordinates etc. is prone to such failure, but there are better
>> methods. These mouse clicks and keyboard events usually trigger a method
>> call inside the GUI program. If there are any means to call that method
>> directly, you are independent from the graphics itself.
>
> Even if you could get it working reliably, scripting a GUI is going to be slow.
>
> GUIs are only designed to work at human speeds, after all.
>

It might be slow, but look at his request in the OP "automatically 
arranging windows, periodically refreshing applications across multiple 
desktops". A button which arranges three programs in a row could be 
useful for some users. Or an automatic reload of a status website inside 
the browser, where you can't change the website to embed autorefresh 
code. I've got a tool running which can remap special keys (ctrl, fn) to 
ordinary chars. Also sometimes a complex functionality is buried in a 
GUI. Consider a server converting MS Word files into PDF. The only 
method which reliably works is COM to drive MS Office, yes it's clumsy, 
but unless you persuade MS to release Office as a Python library you 
have no other option.

Speed is not of any concern here. If execution speed would be important, 
why use Python at all?

	Christian



More information about the Python-list mailing list