-- EvernoteCopyLink.applescript -- Copy title and URL in the front most window of Safari to Evernote with link -- Author: Takanori Ishikawa on copyLinkToEvernote(theTitle, theURL) tell application "System Events" -- copy & paste set the clipboard to theTitle as text keystroke "v" using command down tell process "Evernote" -- Select pasted text -- Note 1: 'ASCII character 28' means 'move left'. -- Note 2: "shift + option" selection might be more efficient, -- but it does not work correctly with Japanese text. (* repeat (length of words of theTitle) times keystroke (ASCII character 28) using {shift down, option down} end repeat *) repeat length of theTitle times keystroke (ASCII character 28) using shift down end repeat -- Link, Add... keystroke "k" using command down delay 0.1 set the clipboard to theURL as text keystroke "v" using command down -- click "OK" delay 0.1 repeat with w in windows if exists sheet 1 of w then click button "OK" of sheet 1 of w end if end repeat end tell end tell end copyLinkToEvernote tell application "System Events" if not (exists application process "Evernote") or not (exists application process "Safari") then display alert "Evernote and Safari Required" message "You have to launch Evernote and Safari before executing script" end if end tell tell first document of application "Safari" set pageTitle to name set pageURL to URL end tell tell application "Evernote" to activate set theClipboard to the clipboard copyLinkToEvernote(pageTitle, pageURL) set the clipboard to theClipboard