Sunday, December 11, 2011

Alfred Extension: Searching Evernote

Tonight I wrote an extension for Alfred that allows you to easily search Evernote.

How To Get It

  1. Make sure you've got the Alfred Powerpack installed (soooooo worth the money and required to use extensions).
  2. Download the extension file: Search Evernote.alfredextension
  3. Simply open that file to install.

How to Use It

The default keyword is "e".

So: simply fire-up Alfred, type "e" a space and your Evernote search.

For help with search check out Evernote's knowledge base article, Using Evernote's advanced search operators.

Why Another Search Extension?

Stephen Millard wrote an extension for searching Evernote. However it had three behaviors I found undesirable:
  1. it opens a new window with each and every search. It's akin to every search to a website spawning a new window.  I prefer to have just one window open, myself. 
  2. it modifies the search query to always be a phrase.  By default Evernote treats each search word independently; if you want to search for a phrase, surround it with quotes.  Millard went out of his way to collapse all search words into a single string.  I'm not sure why.  Personally I'd rather have the option to do either kind of search.
  3. it does not bring Evernote to the front. I'd rather Evernote pop-up in front, showing the results of my search.
Technically, all of this is truly unnecessary. For example, you could define an Alfred Global Hotkey to launch Evernote (say, control+alt+⌘+E) and then hit alt+⌘+F to jump to the search box. For me, it's pretty nice having one place where I search.

How Does It Work?

AppleScript and Evernote's AppleScript API make this task essentially trivial.

This was my first cut at AppleScript (what a nifty little language!) Here's the source for this simple, simple script:

on alfred_script(query)
tell application "Evernote"
 if (exists first window) then
  set first window's query string to query
  open collection window with query string query
 end if
end tell
end alfred_script


No comments:

Post a Comment