sballin / alfred-search-notes-app

Use Alfred to quickly open notes in iCloud/Apple Notes.
https://www.alfredforum.com/topic/11716-search-appleicloud-notes/
MIT License
510 stars 24 forks source link

Alfred note search fails after Notes.app search #8

Closed sballin closed 4 years ago

sballin commented 5 years ago

To reproduce:

sballin commented 4 years ago

Came up with this neat way to clear a search before displaying the requested note:

tell application "System Events"
    tell process "Notes"
        try
            -- If cancel button is present, user has done a search that needs to be cleared
            -- Note: breaks if you set a variable to refer to the text field 
            -- Note: assumes default toolbar layout
            if number of buttons in text field of group 5 of toolbar 0 of window 0 is 2 then
                click button 2 of text field of group 5 of toolbar 0 of window 0
                key code 48 -- tab to unfocus text field
            end if
        end try
    end tell
end tell
...
show note id q in default account
...

But the simpler and more robust solution is...

show note id q in default account
show note id q in default account
sballin commented 4 years ago

Fixed as of version 2.2.0.