This Week's Sponsor:

Listen Later

Listen to Articles as Podcasts

Quickly Append Browser URLs To Evernote with Keyboard Maestro

I often come across webpages and interesting links that I can’t check out right away, but that I also don’t want to send to Instapaper, Pinboard, or my OmniFocus inbox. They are, put simply, “stuff to check out”; I append these URLs to an Evernote note carrying the same name:



As I detailed in my review of Drafts 3.0 for iOS, appending text from an iPhone or iPad is easy with Agile Tortoise’s app and a combination of Evernote actions and browser bookmarklets, but I had to think of an equally straightforward workflow for the Mac. Unfortunately, the lack of a Drafts app for OS X forced me to resort to AppleScript to achieve the same kind of functionality, but the deal was (partially) sweetened by the new features introduced in Keyboard Maestro 6.0, released back in May.



As on the iPhone and iPad, I want to be able to take the current tab in my web browser of choice (Google Chrome) and append it (alongside a date) to the bottom of the “Stuff To Check Out” Evernote note with the following format:

Webpage name
Webpage URL

As you can see, after appending text to an existing note, I want to use two linebreaks to separate the three pieces of data that I want to save. And because I’m on a Mac, I want to be able to create a macro that can be activated by a single keyboard shortcut, that runs in the background without making me jump between apps, and that sends a local notification when it’s done. That’s easy with Keyboard Maestro.[1]

One of the best features of Keyboard Maestro 6.0 is the all new set of browser actions and tokens to get data from the browser without having to use AppleScript. In previous versions of Keyboard Maestro, something as simple as getting the name of the current tab in Google Chrome would have required at least three lines of AppleScript:

tell application “Google Chrome”
 get title of active tab of window 1
end tell

In Keyboard Maestro 6.0, all you have to do is setting a variable to the following value:


…Which is a token that will always return the name of the active Chrome tab as text. The same works with Safari using %SafariTitle% and other kinds of data, such as dates.

To build the “append tab to Evernote” macro, we only need five Keyboard Maestro actions. In the first three ones, we’ll generate a date (formatted in ICU) and grab the current browser tab’s title and URL, saving them to three separate variables. In Keyboard Maestro, you’ll see a preview of the browser tokens directly inside the action cells.



The “core” of the workflow is the AppleScript we’ll use to append text to an existing Evernote note called “Stuff To Check Out”. I tweaked this old script by Bruce Timberlake, which takes advantage of Evernote’s find notes, create note, and append commands and still works with the most recent release of Evernote for Mac.

tell application "Keyboard Maestro Engine"
	set KMVarTitle to get value of variable "browsetitle"
	set KMVarURL to get value of variable "browseurl"
	set KMVarDate to get value of variable "browsedate"
	set KMAppend to "\n\n" & KMVarDate & "\n" & KMVarTitle & "\n" & KMVarURL
	tell application "Evernote"
		set foundNotes to find notes "notebook:\"" & "Inbox" & "\"" & " intitle:\"" & "Stuff To Check Out" & "\""
		set found to ((length of foundNotes) is not 0)
		if not found then
			set curnote to create note with text KMAppend title "Stuff To Check Out" notebook "Inbox"
			repeat with curnote in foundNotes
				tell curnote to append text KMAppend
			end repeat
		end if
	end tell
end tell

Lines 2–5 tell the Keyboard Maestro Engine process to get the values of three variables we saved earlier in the macro and pass them to three new variables that we can use in the script. On line 5, these variables are concatenated in a single one that uses \n to indicate linebreaks.

The actual Evernote script runs between lines 6 and 17. The script asks Evernote to look for a note called “Stuff To Check Out” in the notebook “Inbox”; if a note with a matching name is found, text is appended to the bottom of the note (line 13); if a note is not found, a new one with the selected name and text is created in the “Inbox” notebook (line 10); last, Evernote syncs to save changes to the cloud (line 16). The result will be something like this:



And, at the end of the macro, a native notification will be displayed, confirming that the text has been appended.



I use this macro on a daily basis when I’m working at my Mac, as it provides a simple and effective way to save URLs in a temporary location (that syncs across devices) without having to clutter my OmniFocus inbox or Pinboard account. I didn’t add checks to see if Chrome or Evernote are running, but the macro is highly customizable both in terms of actions you can add and modifications you can make to the AppleScript (for, say, changing the title of the note, format of date, or destination notebook). You can download the macro here.

  1. And you thought I was done with finding ways to automate my Mac. ↩︎

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.