[Pythonmac-SIG] Using appscript for GUI interaction, button click

Charles Miller cmiller at securityevaluators.com
Sun Sep 13 04:42:12 CEST 2009


I'm trying to perform the following applescript with the appscript  
Python module:

tell application "System Events"
	tell process "Preview" to click button "OK" of every window
end tell

Is this possible?  The closest I got was

import appscript
appscript.app('System  
Events').processes['Preview'].windows[1].buttons[1].click()

but I get the error:

Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "build/bdist.macosx-10.3-fat/egg/appscript/reference.py", line  
492, in __call__
appscript.reference.CommandError: Command failed:
		OSERROR: -609
		MESSAGE: Connection is invalid.
		COMMAND: app(u'/System/Library/CoreServices/System  
Events.app').processes['Preview'].windows[1].buttons[1].click()

Any advice or know of documentation that would help me?

Thanks.

Charlie



More information about the Pythonmac-SIG mailing list