Re: applescript and Preview
Re: applescript and Preview
- Subject: Re: applescript and Preview
- From: kai <email@hidden>
- Date: Mon, 16 May 2005 02:23:08 +0100
On Sunday, May 15, 2005, at 06:15 pm, Hernan Ochoa wrote:
I'm tryng to script Preview, but for some reason, it is failing.
Here's the code:
tell application "System Events"
tell process "Preview"
tell menu bar 1
click menu item "save as..." of menu "file"
end tell
end tell
end tell
but I get the following error:
process "Preview"
"System Events got an error: NSReceiverEvaluationScriptError: 4"
Is there another way to do this?
I don't get the same error as you do, Hernan - but your script still
fails here, albeit silently.
A couple of points: Firstly, for many UI commands, you usually need to
bring the target process to the front. Secondly, Preview's "Save As…"
command ends with an ellipsis (option-;), rather than three periods.
This works here:
----------------
tell application "System Events"
tell process "Preview"
set frontmost to true
tell menu bar 1
click menu item "Save As…" of menu "File"
end tell
end tell
end tell
----------------
And so does this:
----------------
tell application "System Events"
set process "Preview"'s frontmost to true
keystroke "s" using {shift down, command down}
end tell
----------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden