State of play with Ulysses?

My pleasure — thank you for your tireless work in trying to solve this!

I do have the latest script, version 275.

However, no major change in behavior. With Ulysses open and focus on any part of the UI, and I hit shift-Cmd-spacebar, the Hookmark (Hm) window appears with the by now familiar “No linkable item found in Ulysses” notification.

Small changes have occurred, however.

First, I no longer have to give Hm permission to access Ulysses every time I invoke Hm — Hm appears to have remembered my “yes” from a previous session, and now accesses Ulysses automatically.

Second, before the Hm window appears, I hear two clicks that sound like my system is copying something. Then the Hm window appears. Then I hear a third copy-to-clipboard click. (There is nothing new in the clipboard, however.)

Thanks for any further thoughts you may have on resolving this.

One non-Hm workaround is to highlight sheet X in the sheet list, and hit shift-Ctrl-Opt-C (or Ctrl-Opt + click with trackpad), which allows me to select “Copy Callback URL”. I can use this URL to hyperlink directly to sheet X.

Any way to “hook onto" this functionality with Hm? (Sorry again for the noob dreamworld talk here….)

Sorry the fix does not work for you.

Could you please select a note in Ulysses, then run the following script in Script Editor?

Script

-- if the title repeatedly says  "title-callback"
-- in Terminal do defaults delete com.cogsciapps.hook auth_id
-- see https://discourse.hookproductivity.com/t/hook-cannot-get-title-from-ulysses-sheet/4593/7
use framework "AppKit"
use scripting additions
use framework "Foundation"


set langStr to ""
try
	set resultText to (do shell script "defaults read com.soulmen.ulysses-setapp AppleLanguages")
	set langIDs to {}
	set {TID, text item delimiters} to {text item delimiters, quote}
	set resultItems to text items of resultText
	text item 1 of resultText
	set text item delimiters to TID
	repeat with i from 1 to (count resultItems)
		if i mod 2 = 0 then set end of langIDs to resultItems's item i
	end repeat
	set langStr to first item of langIDs
	
end try


if langStr is missing value or langStr is "" then
	set langStr to first item of (current application's NSLocale's preferredLanguages as list)
end if
set langID to text 1 thru -4 of langStr
set revealInGroup to "Reveal in Group"
--display dialog langID
set fileMenu to "File"
if langID = "zh-Hans" then
	set revealInGroup to "在组中显示"
	set fileMenu to "文件"
else if langID = "zh-Hant" then
	set revealInGroup to "在群組中顯示"
	set fileMenu to "檔案"
else if langID = "de" then
	set revealInGroup to "In Gruppe anzeigen"
	set fileMenu to "Ablage"
else if langID = "es" then
	set revealInGroup to "Mostrar en el grupo"
	set fileMenu to "Archivo"
else if langID = "fr" then
	set revealInGroup to "Afficher dans le groupe"
	set fileMenu to "Fichier"
	
else if langID = "ja" then
	set revealInGroup to "グループに表示"
	set fileMenu to "ファイル"
else if langID = "ko" then
	set revealInGroup to "그룹에서 보기"
	set fileMenu to "파일"
else if langID = "it" then
	set revealInGroup to "Mostra nel gruppo"
	set fileMenu to "File"
	
else if langID = "pt" then
	set revealInGroup to "Mostrar no Grupo"
	set fileMenu to "Arquivo"
	
end if



-- get Ulysses authorization token
try
	set authId to (do shell script "defaults read com.cogsciapps.hook-setapp  auth_id")
on error errMsg
	open location "ulysses://x-callback-url/authorize?appname=Hookmark&x-success=hook://authorization-callback/access-token///"
	return
end try

-- wait until shift and ctrl keys aren't held down
property NSEvent : a reference to current application's NSEvent
property NSShiftKeyMask : a reference to 131072
property NSControlKeyMask : a reference to 262144

set interfering_modifier_down to true
repeat while interfering_modifier_down
	set modifier_flags to NSEvent's modifierFlags()
	set shift_down to ((modifier_flags div (get NSShiftKeyMask)) mod 2) = 1
	set control_down to ((modifier_flags div (get NSControlKeyMask)) mod 2) = 1
	set interfering_modifier_down to shift_down or control_down
end repeat

tell application "Ulysses"
	activate
end tell

-- Select Sheets or Library
tell application "System Events"
	tell process "Ulysses"
		
		repeat 50 times
			if not enabled of menu item revealInGroup of menu 1 of menu bar item fileMenu of menu bar 1 then
				key code 123 using {option down, command down}
			else
				exit repeat
			end if
		end repeat
	end tell
end tell
set the clipboard to ""

delay 0.2
-- get item ID
tell application id "com.soulmen.ulysses-setapp"
	
	tell application "System Events"
		keystroke "c" using {option down, control down, command down}
	end tell
end tell
delay 0.1

repeat 25 times -- poll clipboard for ~2.5 seconds
	try
		set s to (the clipboard)
		
		if s is not equal to "" then
			exit repeat
		end if
	end try
	delay 0.1
end repeat
set AppleScript's text item delimiters to "id="
set itemId to text item 2 of s

-- use x-callback to get title
tell application id "com.soulmen.ulysses-setapp"
	set myUrl to "ulysses://x-callback-url/get-item?id=" & itemId & "&recursive=NO&access-token=" & authId & "&x-success=hook://title-callback/targetName///?"
	open location myUrl
end tell
get "ulysses://x-callback-url/open?id=" & itemId

Thank you

I did as you directed.

After running the script, focus shifted to Ulysses as desired.

After a couple-second pause, Script Editor returns this error message:
Can’t get text item 2 of “”.

FYI / FWIW, when I select a sheet in Ulysses and invoke Hookmark, I get a 4-5 second pause, and then the familiar "No linkable item found in Finder” error message appears in the Hookmark window.

Thanks again for investigating this!

It could be you have different the keyboard shortcuts.

Could you please try the following shortcuts and see if they work?

  1. short cut for enabling Reveal in Group menu item in File menu
    option+command+left arrow key

After type the above shortcut, “Reveal in Group” menu item is enabled, note entry is selected and highlighted
2. shortcut for copying note url
option+control+command+c

This shortcut will copying the note url.

Thank you

I guess the problem lies in the difference between App Store version and Setapp version.
Today I’m moving from the official version of Hookmark to Setapp’s, and everything works great except for Ulysses (App Store version, which worked before).

When I evoke Hookmark in Ulysses (App Store), it always reminds me “Hookmark would like to access your Ulysses library.” However, it appears every time even though I press Allow over and over again.
image

And then I tried Ulysses in Setapp version. Hookmark worked, but no completely. It seems that Hookmark cannot get the title of Ulysses(Setapp) but just a “title-callback” in the Hook window.

I hope this issue could be solved.

Sorry about this issue.

Could you please
(1) keep only Hookmark-setapp on your mac, remove the Hookmark official one
(2) Keep only one version of Ulysses
(3) Run the following command in Terminal:
defaults delete com.cogsciapps.hook-setapp auth_id
(4)Update Hookmark script . The latest version is 308.

See if the issue is resolved.

Thank you

It worked! Thank you very much for your prompt reply and assistance.
This command seems to enable the Setapp version of Hookmark to work with the App Store version of Ulysses, as when I invoked Hookmark in the non-Setapp version, it automatically opened the official version for me.

I’m curious if this method will still work if I consider fully transitioning to software provided by Setapp in the future, such as using Setapp version’s of Ulysses and Hookmark at the same time?

Thank you again for your help!

Thank you for the update! I am glad it works.

In the future, if you want to use Setapp version of Ulysses instead of App Store version of Ulysses, please run the following command in Terminal. The reason for that is that the auth id for App Store Ulysses does not work for Setapp Ulysses.

Thank you

I am very grateful for your help, and I will make a note of this code. Thank you again.

Not sure if this is the right place to post this, but I attempted to use Hook (latest version) with Ulysses (app store latest version) today and I get the “No linkable item found in Ulysses” message.

Sorry about this issue, @cwc .

What’s your script version? You can find it in Hookmark window.

Thank you

I see this in the preferences:

Integration Scripts Bundle version: 314 (Updated 2024-02-07, 06:22)

Thank you, @cwc .

What’s your system language?

Could you please copy the script from Hookmark Preferences window->Scripts->Ulysses (com.ulyssesapp.mac)->Get Address, paste in Script Editor and run it? Then paste the result or any error message here.

Thank you

System language is English. Following those steps, I see this:

Can’t get text item 2 of “”.

and in the result section of Script Editor:

error “Can’t get text item 2 of "".” number -1728 from text item 2 of ‘’

Hookmark uses shortcut option+control+command+c to copy the note URL.

If you select a note in Ulysses, type option+control+command+c, what do you get?

1 Like

I had a universal keyboard shortcut (from Keyboard Maestro) using the same keyboard command (option+control+command+c) that was causing a conflict. Removed that and now I can hook documents in Ulysses without a problem. Thanks for helping me work that out, @bchend !