Evernote pulled a stunt that was not appreciated by its Mac users when, in its transition to Evernote 10, it removed AppleScript support.This left its Mac users without local automation. We recommend Evernote users not upgrade to Evernote until Evernote restored automation, which they have not yet done.
So we have produced a UI script version of integration with Evernote. To help people with the transition away from Evernote (or in case they choose to stick with Evernote), here is an integration script that is meant to allow you to use the current version of Evernote (10.something) or the prior one.
Hook Pro users of Evernote can paste this script in Hook > Preferences > Script Editor > Evernote > Get Address. Or you can wait till we make it available to all Hook Updates licensees through Hook’s integration server.
Get Address:
use framework "Foundation"
use scripting additions
on urlDecode(input)
tell current application's NSString to set urlString to stringWithString_(input)
set theDecodedURL to urlString's stringByRemovingPercentEncoding -- 4 is NSUTF8StringEncoding
return theDecodedURL as Unicode text
end urlDecode
set theURL to path to application id "com.evernote.Evernote"
set appBundle to current application's NSBundle's bundleWithURL:theURL
set shortVersionString to (appBundle's objectForInfoDictionaryKey:"CFBundleShortVersionString") as string
tell application id "com.evernote.Evernote"
activate
considering numeric strings
set isLegacy to shortVersionString < "8"
end considering
if isLegacy then
set theItemList to selection as list
if (count of theItemList) is equal to 1 then
set theItem to item 1 of theItemList
return "[" & title of theItem & "](" & «class EV24» of theItem & ")"
end if
return
end if
end tell
set the clipboard to ""
delay 0.03
set theURL to ""
set theTitle to ""
tell application "System Events" to tell process "Evernote"
click menu item "Copy App link" of menu 1 of menu item "Copy Internal link" of menu "Note" of menu bar 1
delay 0.05
repeat 50 times -- poll clipboard for ~2.5 seconds
try
if (the clipboard) is not equal to "" then
set theURL to the clipboard
exit repeat
end if
end try
delay 0.05
end repeat
set the clipboard to ""
delay 0.03
click menu item "Copy Web link" of menu 1 of menu item "Copy Internal link" of menu "Note" of menu bar 1
delay 0.05
repeat 50 times -- poll clipboard for ~2.5 seconds
try
if (the clipboard) is not equal to "" then
set theWebUrl to the clipboard
exit repeat
end if
end try
delay 0.05
end repeat
end tell
if theWebUrl is not "" then
set AppleScript's text item delimiters to {"?title="}
set theTitle to text item 2 of theWebUrl
set theTitle to urlDecode(theTitle)
end if
return "[" & theTitle & "](" & theURL & ")"
In our tests this works fine. But wanted to give Evernote users an opportunity to test/comment on this before rolling out it more generally. Again, this should not affect prior users.
It is somewhat ironic that Evernote chose not to change the bundle ID of Evernote 10, even though it is basically a new app (without local automation). This irony caused us to use a bit of gymnastics in our AppleScript.
We hope that Evernote will provide proper local automation, whether AppleScript, x-callback-url, or other.