Hi, has anyone found a way to make Hook open up NotePlan’s UI when hooking to a new file?
I don’t think it’s possible to implement a “new item” script with UI scripted apps, unless perhaps the resulting URL is predictable. But normally the third-party app needs to be the one to do the URL. Also Hook assumes that the app can change the document title for some reason, and so Hook can handle that; but the title is not as important. The title would get updated by Hook when user invokes Hook on the new item.
Guess what, I’m still trying to decide on a core note-taking tool! And I’m still trying to constrain my decision to one that might work 100% fine with Hook (I hope I’m not wrong about NotePlan). Although NotePlan is still a single developer app, I’m stunned by its progress in the last two years.
You can try my implementation of hooking to the new note. It also creates a note inside Inbox folder and links this note to the «today» note
set noteText to do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv))\" " & quoted form of "[$title]($user_link)" set noteTitle to do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv))\" " & quoted form of "$title" set newNoteURL to "noteplan://x-callback-url/addNote?noteTitle=" & noteTitle & "&folder=Inbox&openNote=yes&text=" & noteText do shell script "open '" & newNoteURL & "'" delay 0.2 set NoteURL to "" set NoteTitle to "" tell application id "co.noteplan.NotePlan-setapp" if version ≥ "2.4.4" then set link to selectedNoteUrl set title to selectedNoteTitle if link is not missing value then set NoteURL to link set NoteTitle to title end if end if end tell do shell script "open 'noteplan://x-callback-url/addText?noteDate=today&mode=append&openNote=no&text=Hook%20Added%20[[" & NoteTitle & "]]'" return NoteURL
Awesome and thanks a lot, @ctrlok, this depends on one having
python (no longer a safe assumption in recent macOS I believe.) It didn’t work on my computer even if I do have python, but most of it worked marvellously from the Script Editor.
UPDATE: deleted the rest of this post since a newer post presents a better start.
set noteTitle to quoted form of "$encoded_title" set noteText to quoted form of "#hook%20from%20%5B$encoded_title%5D%28$user_link%29%0A" do shell script "open 'noteplan://x-callback-url/addNote?noteTitle=" & noteTitle & "&folder=Hook&openNote=yes&text=" & noteText & "'" delay 0.2 set noteUrl to "" tell application id "co.noteplan.NotePlan-setapp" if version ≥ "2.4.4" then set link to selectedNoteUrl if link is not missing value then set noteUrl to link end if end if end tell set textToAppendToDailyNote to "Hooked%20%5B%5B" & noteTitle & "%5D%5D" do shell script "open 'noteplan://x-callback-url/addText?noteDate=today&mode=append&openNote=no&text=" & textToAppendToDailyNote & "'" return noteUrl
After hooking a few things and summoning Hook to navigate to NotePlan from its bookmarks, some things don’t always seem to work entirely coherently. Sometimes NotePlan seems to fail to open up a hooked note. But it’s a very nice start, for sure!
Here’s my daily note after having Hook create 3 new NotePlan notes:
Here’s one of those notes, showing the backlink on top from the daily note:
And the expanded UI tying this up together: