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.
Thanks Luc. NotePlan seems to have a quite solid callback URL scheme. Could that be leveraged? If so, this dynamic walkthrough might also be a fun way to check things out.
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.
@LucB: working from @ctrlok’s script, I got the following working.
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:
Works like a charm, thank you!
The only thing I changed was the tell application line and version checking (I use NotePlan3) to this:
tell application id "co.noteplan.NotePlan3" set link to selectedNoteUrl if link is not missing value then set noteUrl to link end if end tell
I am a newbie, but I would really like to do this with NotePlan. Can someone tell me how or what I’m supposed to do with all of that scripting? It would be very helpful I can follow directions well.
Hi, well I feel a bit shy to observe that finally, I ended up not really using it, b/c I felt building a habit of Hooking to New NotePlan notes was dangerous, as the callback URL’s recipe… isn’t robust. Doing a simple move or rename of the note in NotePlan breaks it, and I’m someone who needs to move or rename things “often”. So I resist helping anyone do something that’s not truly robust. I honestly feel the script is… useless.
The next step would be to contact NotePlan’s developer and ask them to implement robustness in their links, or proper scripting support, which I feel would be much better. Pointing them to this page should be a good starting point to help them understand the issue.
thanks, @danieljomphe . For all: exceptions aside ( per Principles That Determine the URL Scheme Returned by
Copy Link for a Given App – Hookmark) Hookmark uses the 3rd party app’s URL scheme, so it’s up to the third party app to ensure robustness of their URLs. Normally, they are perfectly robust. E.g., I have no concern regarding OmniFocus and DEVONthink links.
If one is in doubt regarding a third-party’s app URL scheme, there are typically very solid alternatives to choose from.