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

Re: UI Printing


  • Subject: Re: UI Printing
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 05 Mar 2010 12:33:48 -0600

Here's the script I'm using that works thanks to Bill Cheeseman's hints ...

set msgFile to alias "OS_X:Users:lutherfuller:Desktop:UI scripts:Kids Book Sale -- 4 Days Only! 0.emlx"
tell application "Mail"
activate
close every window
set download html attachments to true
open msgFile
set download html attachments to false
set winName to (name of window 1)
-- close window winName -- this command works here, but ...
delay 1
-------------------
tell application "System Events"
-- UI elements enabled is true. Set manually.
tell process "Mail"
keystroke "p" using {command down}
delay 1
click menu button "PDF" of sheet 1 of window 1
delay 1
click menu item "Save as PDF…" of menu of menu button "PDF" of sheet 1 of window 1
delay 1
click button "Save" of window "Save" -- save location has been manually set to Desktop
end tell
end tell
-------------------
close window winName -- but this command does NOT work.
end tell

But ...

On Mar 5, 2010, at 11:10 AM, Bill Cheeseman wrote:
That will get you the Save panel, where I expect you'll be doing some more scripting. There used to be problems with the accessibility API, and therefore with GUI Scripting, in Save panels. Good luck.

Notice that I did not try to change the save location. And I don't think I will even try. I wrote this script as a feasibility study for a new feature for another application. The pdf must be saved to the container of the file referenced by the alias msgFile, above. And it has to work properly, every time, on your computer, not mine. I doubt that scripting the location for Save would be reliable.

Considering the universal usefulness of PDF documents, there ought to be a command, in AppleScript or StandardAdditions, that works like this ...

savepdf document <file alias> using application <application specifier> to <location specifier>

Using this, a document named "Kids Book Sale -- 4 Days Only! 0.pdf" would appear in the folder "OS_X:Users:lutherfuller:Desktop:UI scripts:". The script above could be done with ...

savepdf document msgFile using application "Mail" to (container of msgFile)

Simple!

 _______________________________________________
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: 
 >Re: UI Printing (From: Stan Cleveland <email@hidden>)
 >Re: UI Printing (From: Vittorio <email@hidden>)
 >Re: UI Printing (From: Bill Cheeseman <email@hidden>)
 >Re: UI Printing (From: Thomas Fischer <email@hidden>)
 >Re: UI Printing (From: Luther Fuller <email@hidden>)
 >Re: UI Printing (From: Bill Cheeseman <email@hidden>)
 >Re: UI Printing (From: Luther Fuller <email@hidden>)
 >Re: UI Printing (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: On the line GUI scripting
  • Next by Date: Re: On the line GUI scripting
  • Previous by thread: Re: UI Printing
  • Next by thread: On the line GUI scripting
  • Index(es):
    • Date
    • Thread