Evernote: Find in current notebook and the filtered tags

I'm trying to create a macro which will search in evernote for a text in notes with following criteria:

  • Note contains in the current notebook being viewed
  • Note has the tag for which the notes are filtered according to that tag

Basically, I can do that using advanced searchquery:
notebook:NoteBookName tag:tag1 tag:tag2

But how can I get the current notebook name and the selected tag?

I don't understand your request. Could you please provide a real-world screenshot of your starting conditions.

It sounds like to me that you have done the following:

  1. Selected a Tag in the Tag Filer dropdown
  2. Then Selected a Notebook in the Notebook dropdown

If so, how are you wanting to change that?

This is for:
Evernote 6.11.1 (455059) on macOS 10.12.6.

OK, so I did some investigation with UI scripting of Evernote, and I was able to get the Notebook name and Tag name from their filter buttons:

==UPDATED==: 2018-08-15 21:22 GMT-5
β€’ Correct script bug.

tell application "System Events"
  tell application process "Evernote"
    #  set oWin to window 1
    #  set tagFilterBtn to button 3 of UI element 2 of UI element 1 of oWin
    tell UI element 2 of UI element 1 of window 1
      set tagBtn to first button whose description is "Filter by tag"
      set nbBtn to button 5
    end tell
    set helpStr to help of tagBtn
    -->Viewing notes tagged β€œ.NB.IT”
    set quoteOpen to offset of "β€œ" in helpStr
    set quoteClose to offset of "”" in helpStr
    set tagName to text (quoteOpen + 1) thru (quoteClose - 1) of helpStr
    set nbName to name of nbBtn
  end tell
end tell


Does this answer your question?

1 Like

Than you very much @JMichaelTX

How can I get those tagName and nbName as variable in KM?

See KM Wiki article: AppleScript for examples.

Let's know if you have any questions.