Applescript giving error using Evernote's "find notes" verb when application is not open

StackOverflow https://stackoverflow.com/questions/18646847

  •  27-06-2022
  •  | 
  •  

Question

I'm writing an applescript that interacts with Evernote for Mac using a command (in the Evernote Suite in Evernote's dictionary) called "find notes". Here's my script:

tell application "Evernote"
set myNotes to find notes ("intitle:Title")
end tell

It works just fine if I run the script when Evernote is already open, but if Evernote is not already open when I run the script it gives me an error: "Expected end of line but found identifier." The word "notes" in the second line is highlighted.

It behaves the same whether I run it from AppleScript Editor or as a shell osascript.

It seems to be parsing "find" as a complete verb instead of just part of the verb "find notes". But if Evernote is open then it recognizes the full verb and works correctly.

Is there any way to make this work as a script (not compiled) running in an environment where Evernote is installed but may or may not be running?

Was it helpful?

Solution

I believe this is because when you don't give a specific name, it's matching the (normally-running) EvernoteHelper app instead.

I think that as long as you have Evernote itself running at compile time, the correct reference will end up in the script, so a compiled script should fire up Evernote instead of the EvernoteHelper when it's run.

You might find that using the bundle identifier "com.evernote.Evernote" instead of the hardcoded path to the app works, too:

tell application id "com.evernote.Evernote"

(Note the "id" part.)

OTHER TIPS

If anyone else runs into the same problem, it seems to fix it if I specify the full path to the application instead of just the name. So:

tell application "/Applications/Evernote.app"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top