• 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
UI scripting question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UI scripting question


  • Subject: UI scripting question
  • From: Jim Brandt <email@hidden>
  • Date: Wed, 16 Jul 2008 15:13:44 -0500

I'm attempting to set the print page setting in Safari to landscape mode.
Here's the piece of code I'm using to attempt this:


tell application "System Events"
  if process "Safari" exists then
    tell process "Safari"
      set frontmost to true
      click menu item "New Window" of menu 1 of menu bar item "File" of menu bar 1
      delay 1
      click menu item "Page Setup…" of menu 1 of menu bar item "File" of menu bar 1
      click button 2 of radio group 1 of sheet "Page Setup"
    end tell
  else
    tell application "Safari" to activate
    click menu item "New Window" of menu 1 of menu bar item "File" of menu bar 1
    delay 1
    click menu item "Page Setup…" of menu 1 of menu bar item "File" of menu bar 1
    click button 2 of radio group 1 of sheet "Page Setup"
  end if
end tell

The error I get when I run this is:

System Events got an error:
NSReceiverEvaluationScriptError: 4

This is what UI Element Inspector shows when the landscape button is selected:

<AXApplication: “Safari”>
 <AXSheet: “Page Setup”>
  <AXRadioGroup>
   <AXButton: “”>

Attributes:
   AXRole:  “AXButton”
   AXRoleDescription:  “button”
   AXHelp:  “(null)”
   AXEnabled:  “1”
   AXFocused (W):  “0”
   AXParent:  “<AXRadioGroup>”
   AXWindow:  “<AXWindow: “Apple”>”
   AXTopLevelUIElement:  “<AXSheet: “Page Setup”>”
   AXPosition:  “x=609 y=209”
   AXSize:  “w=38 h=38”
   AXTitle:  “”

Actions:
   AXPress - press

I'm guessing that I haven't fully defined the path to the landscape button, but how
do you define it when it's not named?

Jim Brandt
 _______________________________________________
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

  • Follow-Ups:
    • Re: UI scripting question
      • From: Bill Cheeseman <email@hidden>
    • Re: UI scripting question
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: login script
  • Next by Date: Re: UI scripting question
  • Previous by thread: MS PowerPoint Background Images
  • Next by thread: Re: UI scripting question
  • Index(es):
    • Date
    • Thread