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
|