• 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
Page Setup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Page Setup


  • Subject: Page Setup
  • From: Charles Ross <email@hidden>
  • Date: Wed, 11 May 2005 19:56:41 -0700

I'm attempting to write a generic handler that will take an application name, paper size, orientation and scale and set the page setup options of that application to those settings. My first inclination to solve this is to use interface scripting. Getting the Page Setup sheet or window to appear is fairly straightforward, but targeting the interface elements within the Page Setup sheet has proven far more difficult than I thought it would be.

Here is my handler so far:

on PageSetup( appName, paperSize, orientation, scale)
    tell application "System Events"
        tell process appName
            my SelectMenu(appName, "File>Page Setup…")
        end tell
    end tell
end PageSetup

If anyone is interested in how I'm using that second parameter to SelectMenu, let me know and I'll share it here. But suffice it to say that the handler works as I've tested it.

I found a sample script online at http://bbs.applescript.net/ viewtopic.php?pid=35438 that seems to do some of what I want, or at least point me in the direction of what I want. That page has within it the following code snippet:

click pop up button 1 of UI element 1 of UI element 4 of window "Page Setup"
delay 0.2
keystroke "A4"


When I place that snippet after the call to SelectMenu (after replacing 'window "Page Setup"' with 'sheet "Page Setup"' because I'm testing with Preview right now), I get the following error:

System Events got an error: NSReceiverEvaluationScriptError: 4

I've also tried investigating the UI hierarchy with UI Browser and UIElementInispector, neither of which have really helped me to track the hierarchy to the interface elements I need (the Paper Size menu, the Orientation buttons and the Scale field). Beginning with the page setup sheet, UI Browser shows the following hierarchy:

unknown 1-> button "OK" (1), button "Cancel" (2), button 3
text 1
unknown 3 -> unknown 1
pop up button 1

OK, the sample I found online refers to "UI element 4", but I see an "unknown 3", so I tried replacing "UI element 4" with "UI element 3" in my script, but received the same error as before.

Has anyone used GUI scripting to control a Page Setup dialog window/ sheet? I've been working on this for two days, and haven't gotten any further in my code. As a wrinkle in the process, this script will eventually have to work with both Panther and Tiger.

Any help would be greatly appreciated.

Thanks,
Chuck _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Page Setup
      • From: Yvan KOENIG <email@hidden>
    • Re: Page Setup
      • From: Emmanuel <email@hidden>
  • Prev by Date: Re: Working with currently-selected text
  • Next by Date: Re: Page Setup
  • Previous by thread: Re: moving an application window from one display to another
  • Next by thread: Re: Page Setup
  • Index(es):
    • Date
    • Thread