At 10:42 -0600 2/3/10, Steve Alex wrote:
>...probably the first script I've written in years - even using ui
>scripting which came out about the time I stopped using AppleScript.
Wasn't that about the time all the people who could write an AETE for
an application suddenly disappeared into thin air?
>click menu item "PrintÉ" of menu "File" of menu bar item "File" of menu bar 1
That's one thing you can actually do without UI scripting:
tell app "Safari" to print window 1 with print dialog
But you can also set up a virtual printer...
<http://www.caddpower.com/cms/osxmakevirtualprinterpscript.htm>
and tell Safari to
print window 1 with properties {target printer:"my virtual printer"}
The print files are spooled to /var/spool/cups/, which requires root access.
Then convert the resulting PostScript file to pdf using ps2pdf
(do shell script "man ps2pdf")
for which you need ghostscript, which is not a troublesome installation.
Otherwise Preview will automatically convert ps to pdf on opening.
There are other ways of doing it, of course, without involving any
browser but the installations required (eg. ImageMagick and probably
a dozen or so prerequisites) are far beyond the powers of this humble
Mac user.
svg2pdf is much more fun.
JD