Skip to content

Instantly share code, notes, and snippets.

@steveh
Created September 14, 2010 03:10
Show Gist options
  • Save steveh/578465 to your computer and use it in GitHub Desktop.
Save steveh/578465 to your computer and use it in GitHub Desktop.
set myDelay to 0.1
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
-- open the print dialog
click menu item "Print…" of menu 1 of menu bar item "File" of menu bar 1
delay myDelay
click menu button "PDF" of sheet 1 of window 1
delay myDelay
click menu item "Save as PDF…" of menu 1 of menu button "PDF" of sheet 1 of window 1
delay myDelay
-- make sure the desktop is the location for the saved pdf
keystroke "d" using command down
delay myDelay
-- save the pdf
click button "Save" of window "Save"
delay myDelay
click menu item "Close Tab" of menu 1 of menu bar item "File" of menu bar 1
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment