Skip to content

Instantly share code, notes, and snippets.

@benwaldie
Created December 9, 2012 18:34
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benwaldie/4246408 to your computer and use it in GitHub Desktop.
Save benwaldie/4246408 to your computer and use it in GitHub Desktop.
TUAW - Send Keynote Presenter Notes to Evernote with AppleScript
-- Make sure a presentation is opened in Keynote. If not, notify the user and stop.
tell application "Keynote"
if (front slideshow exists) = false then
display alert "Unable to proceed." message "Please open a presentation in Keynote."
return
end if
set extractBody to button returned of (display alert "Would you like to extract slide content too?" buttons {"Yes", "No"}) = "Yes"
-- Target the front presentation.
tell front slideshow
-- Get the name of the presentation.
set thePresentationName to name
-- Retrieve the titles of all slides.
set theTitles to title of every slide
if extractBody = true then
set theBodyText to body of every slide
end if
-- Retrieve the presenter notes for all slides.
set theNotes to notes of every slide
end tell
end tell
-- Prepare the notes as HTML.
set theFormattedNotes to "<html><body><h1>" & "Keynote Presentation: " & thePresentationName & "</h1>" & return
repeat with a from 1 to length of theTitles
set theFormattedNotes to theFormattedNotes & "<h2>Slide #" & a & "</h2>" & return
set theFormattedNotes to theFormattedNotes & "<b>Title: " & item a of theTitles & "</b>" & return & return
if extractBody = true then
set theFormattedNotes to theFormattedNotes & "<b>Body:</b> " & item a of theBodyText & return & return
end if
set theFormattedNotes to theFormattedNotes & "<b>Presenter Notes:</b> " & item a of theNotes & return & return
end repeat
set theFormattedNotes to theFormattedNotes & "</body></html>"
-- Replace any returns with line breaks.
set AppleScript's text item delimiters to {return, ASCII character 10}
set theFormattedNotes to text items of theFormattedNotes
set AppleScript's text item delimiters to "<br>"
set theFormattedNotes to theFormattedNotes as string
set AppleScript's text item delimiters to ""
-- Create the note in Evernote.
tell application "Evernote"
activate
set theNote to create note notebook "Inbox" title thePresentationName with html theFormattedNotes
open note window with theNote
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment