[FIXED] Weird behavior with Drafts

I was trying to add a keyboard shortcut to “Link to New -> Drafts” and ran into a weird behavior. First Hook would crash repeatedly when invoking “LtN -> Drafts”, but work perfectly fine with, for example, “LtN-> BBEdit” which is its current default behavior for me. After restarting my mac and cleaning up some file associations, I now get There is no application set to open the URL tags.txt. when I try to hook tags.txt to a new Drafts note with Hook. Of course, all txt files open properly on my machine (with BBEdit) …

Not sure what’s going on …

Thanks for reporting this, the issue seems to be that the Link to New script is returning the contents of the clipboard before it has finished copying the URL for the new note into the clipboard.

I’ve changed the script and Hook should update it automatically if you’re using the default Drafts scripts, or you can manually update it with this:

tell application "Drafts"
	activate
	tell application "System Events" to tell process "Drafts"
		set the clipboard to "$title"
		click menu item "New with Clipboard" of menu 1 of menu bar item "File" of menu bar 1
		set the clipboard to ""
		click menu item "Link" of menu 1 of menu item "Copy" of menu 1 of menu bar item "File" of menu bar 1
	end tell
	delay 0.1
	get (the clipboard)
end tell

We also have some changes in an upcoming update that should make this kind of error a little less opaque in the future

Please let me know if this doesn’t fix the issue!

Thanks for this. It did update in my version of Hook.
Unfortunately now I have something else hapening:
When I invoke hook and LtN -> Drafts, the Drafts application is activated (menu bar switches over to Drafts) but nothing happens.
If I manually open the drafts window, it’s obviously created a new empty draft which I can start populating (no prefilled title, though)
If I go back to the initial item and reinvoke Hook, the drafts doesn’t appear as a link. But if I ask again LtN -> Drafts I get an error message (Draft not found for UUID).
On a third try, Hook does find the initial draft I’ve typed in, but the Draft not found for UUID error reoccurs …