• 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: Scripting Print Orientation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Print Orientation


  • Subject: Re: Scripting Print Orientation
  • From: Axel Luttgens <email@hidden>
  • Date: Mon, 24 Dec 2007 11:41:05 +0100

On 24/12/07 3:45, Mr. Dan Pouliot wrote:

I have a need to automate printing a web page, and the web page must be printed in Landscape orientation. Apparently no browser supports the css property for page orientation, so that potentially simple solution is not available. I find GUI scripting to be utterly baffling- I can never figure out how to determine how to call a particular element in a dialog box. UIElementInspector yields the following code:


<AXApplication: “Safari”> <AXWindow: “My Web Page”> <AXSheet> <AXRadioGroup> <AXCheckBox>

Attributes:
   AXRole:  “AXCheckBox”
   AXRoleDescription:  “check box”
   AXHelp:  “(null)”
   AXValue:  “1”
   AXEnabled:  “1”
   AXFocused (W):  “0”
   AXParent:  “<AXRadioGroup>”
   AXWindow:  “<AXWindow: “My Web Page”>”
   AXTopLevelUIElement:  “<AXSheet>”
   AXPosition:  “x=896 y=270”
   AXSize:  “w=38 h=38”
   AXTitle:  “(null)”

Actions:
   AXPress - press


And the Perform button even presses the button, but I have no idea how to turn this gobbledygook into an applescript command to press the button. hint hint feature request! Any help would be greatly appreciated!


Assuming the print dialog is displayed, this one works here:

   tell application "System Events"
       tell application process "Safari"
           tell first window
               tell first sheet
                   tell first radio group
                       tell checkbox 2
                           click
                       end tell
                   end tell
               end tell
           end tell
       end tell
   end tell

Note how closely the structure of the code mimics the output of UIElementInspector.
But some experiments are often needed while building such code.
For example, it may prove useful to try such things in Script Editor:


   tell application "System Events"
       tell application process "Safari"
           tell first window
               tell first sheet
                   radio groups
               end tell
           end tell
       end tell
   end tell

so as to know how to refer the radio group from AppleScript before going deeper in the structure.

And, of course, the relevant terminology is provided by the dictionary of System Events, in its Processes suite.

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: 
 >Scripting Print Orientation (From: "Mr. Dan Pouliot" <email@hidden>)

  • Prev by Date: Re: App's added to Dock or not
  • Next by Date: Re: App's added to Dock or not
  • Previous by thread: Re: Scripting Print Orientation
  • Next by thread: Re: Scripting Print Orientation
  • Index(es):
    • Date
    • Thread