My name is Isko Salminen.
I'm an entrepreneur and a web developer living in Helsinki.

Keyboard Maestro Macro: Append text to Evernote note

Edit, Nov 15, 2014: I found a way to work around the issue of not having Evernote running while executing this macro. Check out the updated macro.

Edit, May 8, 2014: As this was originally written in 2012, and as there have been many updates to Evernote and Keyboard Maestro, I updated the macro to work with the latest versions. The updated macro also addresses the focus issue mentioned in the comments by Pawel.

---

Ben Brooks wrote an article on how he uses Keyboard Maestro and a hot key trigger to save and append quotes in a text file for later reference. You can read his article here.

Ben's solution was great but I needed to modify it a bit for me as, instead of a single text file, I wanted to save the quotes in a single Evernote note.

I've never used Keyboard Maestro before but with Ben's macro, some Googling and trial and error I managed to hack together a solutions. Here's how I modified Ben's macro:

append-to-evernote-macro.png

Most of it is the same (I just changed the hot key, a personal preference), but the "Open URL:" is the key part.

For this to work, if you don't already have one, create a new note in Evernote. Also, make sure to sync Evernote at this point. To get the URL for the note, right-click on it and select "Copy note link".

copy-note-linkin-evernote.jpg

This will give you a http:// link to the note. But for this macro to work, you'll need the old evernote:// style link.

Get the evernote:// style link in Evernote

If you use the http:// link in the macro, it won't work. The easiest way I found to get the evernote:// link is to paste the http:// link as plain text to an blank Evernote note (Edit -> Paste As Plain Text).

Now copy this link and paste it as the URL to be opened, and select Evernote as the application to open it with.

How to make the script work even if Evernote is not currently running

Previously, if Evernote wasn’t running in the background, this macro didn’t work. It would open Evernote app and try to append the text, but the macro would finish way before Evernote app was even up and running. 

To work around this issue, I added two extra steps. First, we activate Evernote and bring it to the front. At the same time we pause the script until it detects Evernote is at the front. Then, after opening the note we want to append the text to, we add a small delay until we have the note window open. We check this against the window title (change the Title to what ever you call your note).

This way we only paste the text after 1) we have Evernote running, and 2) we have the right note window open and at the front.

How to fix the focus issue

Evernote used to set the focus on the note body, but ever since the update, it now focuses on the note title instead. To get around this, and to paste the text to the note body, I added an extra Tab-keystroke action before the Insert Text action. This will move the focus from the note title to the body before the text is inserted.

tab-action.png

And that's it. I also made some minor modifications to Ben's append text but this is just for my taste:

%NamedClipboard%Quoted text% | saved %ShortDate% %ShortTime%
%NamedClipboard%URL%
%Return%
---
%Return%
%Return%

You can find more great articles on Ben's Keyboard Maestro series.