Applescript is a PITA: Exporting Keynote as PDF

| | Comments (2)

NOTE: This is for keynote 2, which is bundled with iWork '07. I've posted an updated script for keynote 3.

on run
  display dialog "Drag keynote documents on me to convert to PDF."
end run

on open draggeditems
  repeat with thisFile in draggeditems as list
    tell application "Finder" to reveal item thisFile
    set thisFile to thisFile as alias

    tell application "Keynote" to open thisFile

    tell application "System Events"
      tell application process "Keynote"
        set frontmost to true

        if menu item "Hide Inspector" of menu 1 of menu bar item "View" of menu bar 1 exists then
          keystroke "i" using {command down, option down}
        end if

        click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1

        repeat until sheet 1 of window 1 exists
        end repeat

        tell sheet 1 of window 1
          click radio button "PDF" of radio group 1
          click button "Next…"
        end tell

        repeat until button "Export" of sheet 1 of window 1 exists
        end repeat

        tell sheet 1 of window 1
          click button "Export"
        end tell

        delay 3
        keystroke "w" using command down
      end tell
    end tell

  end repeat
end open

2 Comments

This is truly fascinating, however, I feel I'd like this script more if it were not so clever.

What do you suggest, Seth?

Leave a comment

About this Entry

This page contains a single entry by zenspider published on July 23, 2007 11:15 AM.

Argh! Stop being "clever"! was the previous entry in this blog.

rubyforge version 0.4.3 has been released! is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.32-en