[FIXED] To invoke Hook window in Ulysses one needs to select the doc in the Sheets column (not put the focus in editor). A bug with Ulysses

Update: I got another reply from Soulmen’s, the developers of Ulysses. They stated that due to their big task list, “for the time being, it is not planned to integrate such an API”. They also did not indicate that they would fix the bug with their x-callback-url. At least Ulysses users have a work-around (selecting the document in the Ulysses).

For the growing list of apps known to be compatible with Hook, please see this web page, which includes writing apps such as nvALT, Agenda, Bear, Drafts, Scrivener, Pages, etc. We are quite pleased to support such great writing apps. I’m quite excited about upcoming developments in the automatable Mac writing app space :wink: .

That seems to be the most reliable way. In that case, the document name is lost. In the future, however, Hook will likely enable users to rename links.

I’ve published a video on youtube that demonstrates that

  1. I can invoke a functional Hook window by selecting a document in the middle (“sheets”) column. In that case, I can link the Ulysses doc to a new doc; those links work in both direction. Also, the links are properly named (with the document names). (I also separately tested “Copy as Link”, “Link to Copied Address”, which is not demonstrated in this video).
  2. when selecting the document pane on the right, Hook is not presented (for reasons to do with Ulysses’s x-callback-url response).

Whether the Hook window is presented or not, I often experience a latency between issuing the Hook keyboard shortcut and the Hook window being presented. The video is edited for conciseness, but I a made a note of this in the description of the video itself.

Hopefully the Ulysses developers will soon see the value of providing AppleScript or JavaScript support. That would allow better automation with other tools (like Keyboard Maestro, Alfred and LaunchBar).

As a corollary of this, drag and drop linking on menu bar icon doesn’t work with Ulysses.

I’ve got a working AppleScript but it’s not pretty. Add this below ‘-- wait until shift key isn’t held down’ and above ‘-- get item ID’ in the built-in Hook handling:

– select Sheets column
tell application id “com.ulyssesapp.mac”
activate
tell application “System Events”
keystroke “3” using {command down}
key code 123 using {option down, command down}
end tell
end tell
delay 0.7

That works @stevelw. The response is so deathly slow, unfortunately, that I wouldn’t want to use Hook with Ulysses very often if this is the only solution.

I found a delay of 0.5 works on my system (30% faster response) but I put it up to 0.7 to make it more robust.

Try lowering it and see if that helps.

OK, I got it running, and fixed my error of not allowing you to link to a group in Library. Does this work for you?

Add this below ‘-- wait until shift key isn’t held down’ and above ‘-- get item ID’ in the built-in Hook handling:

-- Select Sheets or Library
tell application "System Events"
	tell process "Ulysses"
		if enabled of menu item "Clear Markup" of menu 1 of menu bar item "Markup" of menu bar 1 then
			-- Editor selected
			-- Select Sheets view
			-- 123 = left arrow key
			key code 123 using {option down, command down}
		else
			-- Editor not selected
			if not enabled of menu item "Reveal in Group" of menu 1 of menu bar item "File" of menu bar 1 then
				-- Attachments selected
				-- Select Sheets view
				key code 123 using {option down, command down}
				key code 123 using {option down, command down}
			end if
			-- Attachments not selected
			-- else Sheets or Library selected already
		end if
	end tell
end tell

I see the above has been added to the built in script. In my experience I have had to add the below delay to get it to work reliably — a smaller delay is probably sufficient, but this is what I ended up with.

key code 123 using {option down, command down}
delay 0.5
key code 123 using {option down, command down}

Here’s an alternate approach which I think we’re going to use

-- Select Sheets or Library
tell application "System Events"
	tell process "Ulysses"
		repeat 50 times
			if not enabled of menu item "Reveal in Group" of menu 1 of menu bar item "File" of menu bar 1 then
				key code 123 using {option down, command down}
			else
				exit repeat
			end if
		end repeat
	end tell
end tell

It might seem crazy to mash ⌥⌘← (up to) 50 times, but the advantage of this is that it doesn’t depend on delays which will be unnecessarily long on some users’ systems and too short on others.

Does this not risk over-shooting and getting the link to the Library item, not the sheet, ending up creating a link to the wrong thing?

Unfortunately nothing is totally safe when you’re doing UI scripting, but I think this is as good as we could hope for.

To overshoot and go from Editor to Library there would have to be a race within Ulysses checking if “Reveal in Group” menu item is enabled, in the middle of handling a keypress. The check would have to take place after Ulysses has received the keypress and started handling it but before it finishes and enables the “Reveal in Group” menu item

I can’t know how Ulysses is implemented, but I expect both of those to happen on the main thread, so they would happen in sequence, and this would be impossible.

Hi, it seems my Hook 1.3.2 is not working with Ulysses 18.5 under Mac OS 10.15.2 anymore. It used to work before I upgraded three of them (Hook, Ulysses, Mac OS) …not sure what is the cause. Anyone has similar experience?

I’ve done a quick test with the SetApp version of Ulysses 18.5 under macOS 10.15.2. It seemed to work fine with the sheets shown (scripts shows them)

Are you using the Mac App Store version?

Thanks for the quick reply. Yes, I use Mac App Store version.

Just to clarify, I can see Hook window pop up very quickly and then disappear.

with the SetApp version of Ulysses and macOS 10.15.2, I’ve just seen an issue with Hooks title bar. However, links works fine so far.

What you’re describing seems to be a timing issue, which can happen with UI scripting. A developer of ours will look at this.

(We will be showcasing some note taking apps, like Bear and Drafts, that adequately support automation. But that’s no consolation to Ulysses users. We encourage Hook users who use Ulysses to request automation support from its developer, SoulMen (their twitter handle is https://twitter.com/ulyssesapp?lang=en)), as I believe several have already.

we mailed them in March and possibly earlier/later. I’ve sent them an email again with details again.
For those who’d rather use twitter than email, here’s my latest tweet to @ulyssesapp . We’re sure SoulMen are very busy people. I certainly understand being in a position where there is a huge pipeline of work and customer demands.

However, I think that the ability to link documents together is of primary importance. Otherwise, an app’s documents/data are sequestered. We know from the web that the ability to link information changes everything. That’s why we’ve built Hook and intend to continue extending its reach.

@LucB Thanks for the efforts. Look forward to solving this issue. I also replied to the tweet.

1 Like

So far, we can’t reproduce this issue. We suspect that there’s a delay on your Mac for some reason that is causing the script to fail. there’s a loop in the Get Address script

	tell process "Ulysses"
		repeat 50 times

Could you please try replacing 50 with 75? It won’t slow down Hook’s responsiveness in the context of Ulysses (or other apps), because the script exits that loop upon success which will normally be earlier than 75.

that’s in Hook > Gear Menu > Preferences menu item > Scripts (tab) > Ulysses (on left) > Get Address (near top of the Scripts tab).

Please be sure to touch the Save button after making the change.

We might tweak this number in the built-in scripts.

Tried 75. Still the same issue but thanks a lot.

Thanks for letting me know this. And very sorry you are running into this.

This means we at CogSci Apps need to provide a way for users to feed the URL of an item from Ulysses (or other UI scripted apps) into Hook so they can retrieve their links in cases where UI-scripting breaks down. For more reliable apps, this isn’t an issue. The workflow might be for the an affected user to

  1. copy the URL themselves from Ulysses into the clipboard,
  2. invoke Hook in the context of Ulysses

if Hook cannot retrieve links but detects that there is a URL in the copy buffer, then it might populate the Hook window with the URLs. This would happen automatically. No extra command required.

In addition, this could be generalized into an additional function that might be handy in other cases, such that the app context would not matter ( something like, show links for address in copy buffer).

The current UI architecture and its direction would support something like this.