• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applescript and Preview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >applescript and Preview (From: Hernan Ochoa <email@hidden>)

  • Prev by Date: Re: Script Editor hangs on "Open Dictionary"
  • Next by Date: Image Events in Tiger Weirdness?
  • Previous by thread: applescript and Preview
  • Next by thread: Re: applescript and Preview
  • Index(es):
    • Date
    • Thread