RE: Scripting - Print/Save PDF As Postscript
RE: Scripting - Print/Save PDF As Postscript
- Subject: RE: Scripting - Print/Save PDF As Postscript
- From: "Scott Babcock" <email@hidden>
- Date: Mon, 15 Aug 2005 22:11:06 -0700
- Thread-topic: Scripting - Print/Save PDF As Postscript
There is a way to do it, if you're not above using keystrokes:
tell application "TextEdit" to activate
tell application "System Events"
-- open the Print sheet
keystroke "p" using command down
-- let the sheet draw
delay 1
-- set focus to the PDF button
repeat 5 times
keystroke tab
end repeat
-- open the menu
keystroke space
-- let the menu draw
delay 1
-- select Save PDF as PostScript
key code 125
key code 125
keystroke space
end tell
This will work with the Print sheet as it exists now. From here, you can
find the Save dialog and party on. There's certainly no guarantee that
this will work tomorrow, since it's totally reliant on tab order and
menu order.
This could certainly be refined to make it a bit more robust - setting
focus to the Preview button and using a single <shift-tab> to select the
PDF button, using the [File | Print...] menu instead of <cmd-p>, waiting
for the sheet to exists instead of blindly waiting 1 second.
As Bill indicates, the UI elements associated with this control don't
expose any actions through System Events. The interesting things are
that you can tweak this control using Accessibility Inspector if you
find it with the mouse, but you can't find it searching through the
Print sheet hierarchy.
> -----Original Message-----
> Date: Mon, 15 Aug 2005 17:59:00 -0400
> From: Bill Cheeseman <email@hidden>
> Subject: Re: GUI Scripting - Print/Save PDF As Postscript
> To: AppleScript-Users Mail <email@hidden>
> Message-ID: <BF268864.27151%email@hidden>
> Content-Type: text/plain; charset="US-ASCII"
>
> on 2005-08-15 4:53 PM, email@hidden at
email@hidden
> wrote:
>
> > has anyone found a way to automagically select this option via the
Mac
> OS X
> > 4.x GUI scripting?
>
> Not me, and I've tried. I got it working in Panther, but the Tiger
version
> is much more complex and doesn't seem to respond to GUI Scripting.
>
> > <g> ... it really looks as if
> > they have used a custom control for presenting a list, its hard to
> understand
> > how this was seen to be a good choice?
>
> I believe it's a pretty ugly hack, implemented in such a way that it
> responds to commands that are listed in a folder in one of the system
> library folders -- I forget where. In Panther, you could turn the
popup
> menu
> back into a simple button by removing items from the folder; I haven't
> tried
> that in Tiger. Clever tricks like this are often implemented without
> regard
> to accessibility.
>
> --
>
> Bill Cheeseman - email@hidden
> Quechee Software, Quechee, Vermont, USA
> http://www.quecheesoftware.com
>
> PreFab Software - http://www.prefab.com/scripting.html
> The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
> Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
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