Yes, that worked, thanks. Also, thanks for the advice to use
ASTranslate. I've had no formal idea how to do the translation from
apple script to appscript and so mostly just guess and use common
sense, which obviously doesn't always work! Thanks again!!!
Charlie
On Sep 13, 2009, at 12:52 PM, has wrote:
Charles Miller wrote:
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
If you're not sure how to translate an AppleScript command to the
equivalent appscript syntax, ASTranslate is your friend:
app(u'System
Events').processes[u'Preview'].windows.buttons[u'OK'].click()
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()
Error -609 means either the target application unexpectedly quit
while handling the event, or the command didn't complete within the
allotted timeout period (which should be error -1712, but the Apple
Event Manager sometimes returns the wrong code). So does the
original AppleScript work? If not, the problem is in what you're
trying to do. If it does, then see if the ASTranslate-based
translation works.
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig