• 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: CYB <email@hidden>
  • Date: Wed, 10 Mar 2010 17:51:20 -0600
  • Thread-topic: Selecting a pop up button value in a Print dialog

Title: Re: Selecting a pop up button value in a Print dialog
Is there a way to select an item of a pop up button in a print dialog sheet?

I have a script that logs on to a web page and "prints" that page to a PDF file using the print dialog to save as PDF. One of my printer presets is a Grayscale option, and Preview saves the file without color. I'm able to detect that this option is set, via the following code, when the "Print" sheet is open:

tell application "System Events"
  tell process "Safari"
    set nm to name of front window
   set x to value of pop up button 2 of sheet "Print" of window nm

   ...

However this code does NOT work:

   if x contains "Grayscale" then
     set value of pop up button 2 of sheet "Print" of window nm to "Front tray-2 Side Color Economy 1"
    end if

So my questions:

1) Is there a way to select one of the other options of this pop up button?

2) Since these options vary from printer to printer based on saved options established by the user of the printer, is there a way to obtain all the possible available values?

TIA

Jim

Jim, maybe this snippet that I use years ago can help you in the process, it not use Safari but, as you can see it ask about the name of presets, and react after getting the result.

-- start snippet
tell application "System Events" -- GUI
            tell process "Photoshop"
                click menu item "Print..." of menu of menu bar item "File" of menu bar 1
                click pop up button 2 of window "Print"
                delay 0.5
                keystroke (ASCII character 3) -- enter key
                repeat
                    set Preset to get value of pop up button 2 of window "Print"
                    if Preset is equal to "AA Kodak luster rollo250 720dpi" then
                        exit repeat
                    else
                        if Preset is equal to "Standard" then
                            click pop up button 2 of window "Print" --open again menu "Pressets"
                            delay 0.5
                            keystroke (ASCII character 31) -- down arrow key
                            keystroke (ASCII character 31) -- down arrow key
                            delay 0.5
                            keystroke (ASCII character 3) -- enter key
                            delay 0.5
                            exit repeat
                        else
                            click pop up button 2 of window "Print" --open menu "Pressets"
                            delay 0.5
                            keystroke (ASCII character 30) -- up arrow key
                            delay 0.5
                            keystroke (ASCII character 3) -- enter key
                            delay 0.5
                        end if
                    end if
                end repeat
                delay 0.5
                keystroke CantidadImpresosCarta — this is the number of copies for print
                click button "Print" of UI element 5 of window "Print" --print
                delay 16
            end tell
        end tell
-- end of snippet

The trick is that your preset have a name that you always know where in the mane is it, for that reason I named it starting whit a “AA” to ensure that is always on top of my list immediately after “Last User settings”

Carlos Ysunza B.
Director
Ysunza/Santiago
Visual Communication • Automation
Tel. (52)55 5256-0336
email@hidden

http://www.ysunzasantiago.com
http://www.thesecretmexico.com
http://www.softrobot.com.mx

 _______________________________________________
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: 
 >Selecting a pop up button value in a Print dialog (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Replace cover page using applescript in Acrobat
  • Next by Date: Re: Jon's commands renameFile not working?
  • 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