Drafts: Problem with multiple Desktop Spaces

I use several Desktop Spaces. I’ve linked an email and a Drafts draft.

When I try to switch to the Drafts entry and Drafts is not on the Desktop Space where Mail resides, Drafts is only activated (in the Menu bar) but the text not displayed or the Desktop Space changed to the one with Drafts.

A workaround I found is to set Drafts’ option to “All Desktops”. However, I’d like also to use the option “None” or “This Desktop”.

I haven’t tried if this a general bug or only related to Drafts but I assume it is a general bug.

Does this work if you use it for the Drafts ‘Open Item’ script?

set note_link to “$0”
tell application “Drafts”
activate
open location note_link
end tell

Unfortunately not in Hook.

(It works in Script Editors after I changed the opening ".)

What if you move the open command out of the tell block?

set note_link to “$0”
tell application “Drafts”
  activate
end tell
open location note_link

Remember to set a scheme name for Drafts as it is blank by default as it doesn’t have an open script

I’m sorry to tell you that this script also does not work.

I’m not sure about the scheme on the “Open Item” tab. Hook seems to use “hook:///identifier”, e. g. “hook://devonthink/B2375915-576D-4A23-904D-07D13F99B11A”, so “devonthink” needs to be placed into the scheme field.

The Drafts scheme is saved as “drafts5://open?uuid=26A7E789-E2C8-4B2C-8D4B-C324D585D661” (without “hook://”).

I tried “Drafts”, “drafts5”, and even “drafts5://open?uuid=” in the scheme field. What do I need to put there?

On the other hand, it might be a problem with macOS. I found a discussion that AppleScript “open location” was broken in 10.12.5. I’m not sure if that is still the case but when I call the above drafts URL in Safari, Drafts is also only activated but the Desktop Space is not changed either (macOS 10.14.5 public beta).

Hello, I’m one of the developers. stevelw had the exact right idea. Try setting the scheme to drafts5 and the ‘Open Item’ script to

tell application "Drafts"
	activate
end tell
open location "$0"

Only new links will work, any links you copied from a draft before changing the scheme will still be broken. I’m afraid you will have to delete and recreate them.

This is an issue with Drafts. As you’ve observed, Drafts doesn’t activate correctly if you open a URL while the app window is open in a different desktop space. This happens whether you open the URL in Hook, or Safari, or Terminal, or any other context.
I’ve reported the issue to their support team.

1 Like

When a URL is opened, macOS chooses an application to handle it based on the first segment of the URL, the scheme e.g. “http(s)” for web browsers, “drafts5” for Drafts, “hook” for Hook

What setting the ‘scheme’ field to “drafts5” does is make Hook copy URLs from Drafts as “hook://drafts5/…” instead of “drafts5://…” Since the scheme of the URL is “hook”, macOS opens these URLs with Hook.

Since the only problem with Drafts is that it doesn’t activate correctly, all Hook needs to do is activate Drafts before opening the original “drafts5://…” URL and letting Drafts handle it

Thanks for the explanation.

Drafts was recently updated with a fix for “Better handling of activation of the app when no windows are visible.”

Now everything is working as expected. Thanks!

1 Like