Evernote Search Snippet

Here’s an extension snippet that searches (new) Evernote for a string.

It’s useful, since Evernote doesn’t integrate with Spotlight. Took me a while to work it out, so I’m sharing it here.

-- #popclip
-- name: Evernote search
-- icon: search filled E
-- language: applescript
-- script:
tell application "Evernote"
	activate -- Launch or bring Evernote to the front
end tell

delay 1 -- Allow time for Evernote to become active

tell application "System Events"
	-- Bring Evernote's search field into focus
	keystroke "f" using {command down, option down}
	delay 0.2 -- Small delay to ensure the search field is ready
	
	-- Clear the search field
	keystroke "a" using {command down} -- Select all text in the search field
	delay 0.5
	key code 51 -- Simulates pressing the Delete key
	
	-- Enter the new search term
	keystroke "{popclip text}" -- Replace with your desired search term
	key code 36 -- Simulates pressing the Return key
end tell

1 Like

… Except that if you use it from a Chrome browser it does the search in Google! Any suggestions why, and how to fix that, please?

Could it be that you need to add a loop to detect if Evernote is the frontmost app? Time delay alone will not always cut it.

There is an example of this in Music extension.