Selected note doesn't open
Closed this issue · 7 comments
- Search for a note with
n <query>
↵ Enter
- If you're already in a note in the Notes app, the notes app will appear, but the old note still stays visible
- If the Notes app is in the folder view, the selected note is highlighted, but not opened
- macOS version?
- Alfred version?
- In System Preferences > Security & Privacy > Privacy, there are checkmarks for Accessibility > Alfred 4, Full Disk Access > Alfred 4, Automation > Alfred 4 > Notes, and Automation > Alfred 4 > System Events?
- What is the output of the debug log when your error happens?
-
MacOS: 10.15.6
-
Alfred: 4.3
-
Verified that
Alfred 4
has all of the permissions you mentioned
Output Log
[13:03:11.069] Search Notes[Script Filter] Script with argv 'golf' finished
[13:03:11.100] Search Notes[Script Filter] {
"items": [
{
"title": "Golfing",
"subtitle": "Notes",
"arg": "x-coredata://4E224CCE-DD8D-417D-B922-DD0E9F4F45EA/ICNote/p257?golf",
"quicklookurl": null
},
{
"title": "Golf Club Buying",
"subtitle": "Archive",
"arg": "x-coredata://4E224CCE-DD8D-417D-B922-DD0E9F4F45EA/ICNote/p156?golf",
"quicklookurl": null
}
]
}
[13:03:21.001] Search Notes[Script Filter] Processing complete
[13:03:21.002] Search Notes[Script Filter] Passing output 'x-coredata://4E224CCE-DD8D-417D-B922-DD0E9F4F45EA/ICNote/p257?golf' to Run NSAppleScript
[13:03:21.136] Search Notes[Run NSAppleScript] Processing complete
[13:03:21.149] Search Notes[Run NSAppleScript] Passing output '' to Run Script
Thanks, that all seems normal... Are you viewing your notes in gallery mode? I made this workflow with list mode in mind, but can reproduce what you report when I switch to gallery.
You can try pasting the following to replace the script that has the description "Show note/folder or create note". I'm not a big fan of the delay required for it to work, and it doesn't work if the Notes in-app search is active.
on alfred_script(q)
tell application "Notes"
if q contains "/ICNote/p" then
activate
tell application "System Events" to key code 53 -- escape
-- Show user requested note
-- Get note id which is first item in q
set noteID to text 1 thru ((offset of "?" in q)-1) of q
show note id noteID in default account
show note id noteID in default account
delay 0.3
tell application "System Events" to key code 76 -- return
else if q contains "/ICFolder/p" then
-- Show user requested folder
-- Get folder id which is first item in q
set folderID to text 1 thru ((offset of "?" in q)-1) of q
show folder id folderID in default account
show folder id folderID in default account
else
-- Create new note from user query
-- Move from any other folder/state to default "Notes" folder
show default folder in default account
show default folder in default account
tell application "System Events"
tell process "Notes"
click menu item 1 of menu 3 of menu bar 1 -- File, New Note
set clipboardOld to the clipboard
set the clipboard to q
click menu item 6 of menu 4 of menu bar 1 -- Edit, Paste
click menu item 1 of menu 5 of menu bar 1 -- Format, Title
key code {36, 36} -- press enter twice
delay 0.1
set the clipboard to clipboardOld
end tell
end tell
end if
end tell
end alfred_script
Yeah, that isn't super bulletproof either -- it still doesn't work when the Notes app is already on a different note (first bullet point in the original issue description above).
Anyways, I appreciate you trying to help me out here -- I think I'll just switch to the list view for now for the path of least resistance (I may switch to something like markdown files or Bear at some point anyways).
~~~~~
As a side note, do you have any advice and where to find documentation on writing AppleScript? I'd love to be able to debug/write AppleScript and solve these problems for myself, but the whole thing is super daunting and confusing to me right now:
- The syntax is weird, and I haven't been able to find a resource for it
- Even when you look up an app's documentation in
Script Editor.app
, it's like, yeah here are your objects and APIs -- but it's still confusing on how I actually go about using them in a real script
Applescript is unfortunately not very well documented. I mostly learned by googling, dictionaries, and looking at unrelated scripts people have written. There's a paid app called Script Debugger which helped me out when I was new to it. One very handy command is "get properties of blah". For UI scripting the Xcode Accessibility Inspector is very useful.