Save as PDF through UI Scripting

I’m trying to write a script that will use UI scripting to choose “Save as PDF” from the button “PDF” of a print window.

I think I’ve found the right names for these items using Apple’s Accessibility Inspector, but I can’t seem to figure out how to refer to the parent (the print window). I would assume it would be “sheet ‘x’” but I have no idea how to find “x”. Can anyone lend me a hand here?

I’m using TextEdit for an example (assuming a document is already open)…

tell application "TextEdit" to activate
tell application "System Events" to tell process "TextEdit"
	click menu item "Print." of menu "File" of menu bar 1
	click menu item "Save as PDF." of menu button "PDF" of sheet
end tell

Hi,

take a look at this thread

Cool… Thanks.

I may have some more questions later, but thank you… This should work perfectly.