It is because Hook communicates with Obsidian and Craft using x-callback-url, which is asynchronous. while we are trying to find a solution, could you please try using Hook’s global shortcuts for copy link or copy markdown link to get the bookmark?
set the clipboard to ""
delay 0.2
tell application "System Events" to tell process "Hook"
keystroke "m" using {control down, shift down, command down}
delay 0.1
repeat 10 times -- poll clipboard for ~2.5 seconds. Sometimes set x to the clipboard throws exception
try
set theBookmark to the clipboard
if theBookmark is not equal to "" then
exit repeat
end if
end try
delay 0.1
end repeat
end tell
get theBookmark
set fileName to "tbd"
set hook_link_url to "tbd"
tell application "Hook"
set note_bookmark to (bookmark from active window)
set fileName to name of note_bookmark
set hook_link_url to address of note_bookmark
end tell
bookmark by request handle v : Get a bookmark for the specified asynchronous request handle (ID) that was previously returned by Hook’s “bookmark from active window” command. This is typically useful for apps controlled by x-callback-url.
**bookmark by request handle text **: request handle
bookmark from active window v : Get a bookmark for the currently selected or currently open item of the active window of the active app. However, if Hook cannot immediately return such a bookmark for the item (e.g., in case of apps with which Hook uses x-callback-url), then you’ll receive an asynchronous request handle (ID) for this item. In the latter case, you can subsequently apply the request handle (ID) to Hook’s “bookmark by request handle” command to get the bookmark you need.
bookmark from active window
→ bookmark or text : a bookmark or a request handle
test script for Obsidian
tell application "Obsidian"
activate
end tell
tell application "Hook"
delay 1
set currentBookmark to bookmark from active window
if class of currentBookmark is text then
repeat 50 times
try
set b to bookmark by request handle currentBookmark
if b is not missing value then
return b
end if
end try
delay 0.1
end repeat
else if class of currentBookmark is bookmark then
get currentBookmark
end if
end tell
coming soon
The next release of Hook will contain the updated AppleScript dictionary documentation.
Is there any examples of using x-callback-URL instead of this script below @LucB
tell application "Hook"
set note_bookmark to (bookmark from active window)
set fileName to name of note_bookmark
set hook_link_url to address of note_bookmark
end tell