• 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: Selecting a pop up button value in a Print dialog
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting a pop up button value in a Print dialog


  • Subject: Re: Selecting a pop up button value in a Print dialog
  • From: Axel Luttgens <email@hidden>
  • Date: Thu, 11 Mar 2010 14:13:17 +0100

Le 10 mars 2010 à 22:50:40, Jim Brandt a écrit :

> Axel,
>
> Your code didn't work for me (I'm still running 10.4.11 Tiger on a PowerPC).
> The event log shows the line as if it executed but nothing happens, the name of menu items command returns an empty list and the tell menu item 1 perform action "AXPress" gives a System Events got an error: NSReceiverEvaluationScriptError: 4 error (which makes sense since the menu item list is empty.)
>
> Was AXPress something that changed from 10.4 to 10.6?
>
> Any other thoughts?

Yes: it's always a good idea to provide some info about the context. ;-)

So, 10.4.11.
The print sheet displayed by Safari (and provided by the system) has another layout, so that the pop up button of interest is the second one.
On the other hand, it seems that it is mandatory for the target application to be active.
As a result, this one seems to do the job here, with Safari 4.0.3:

tell application "Safari" to activate
tell application "System Events"
	tell application process "Safari"
		tell front window
			tell front sheet
				tell pop up button 2
					-- Display the local menu
					perform action "AXPress"
					tell menu 1
						-- Q2: get available "values"
						name of menu items
						-- Q1: select an option (here, "Save as…")
						tell menu item "Enregistrer sous…"
							perform action "AXPress"
						end tell
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

Of course, as you did in your sample snippet, I'm assuming the printing sheet is already displayed.

HTH,
Axel

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Selecting a pop up button value in a Print dialog (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Osascripting
  • Next by Date: EPS to PDF Watch Folder Dilemma
  • Previous by thread: Re: Selecting a pop up button value in a Print dialog
  • Next by thread: Re: Selecting a pop up button value in a Print dialog
  • Index(es):
    • Date
    • Thread