"bookmark from active window" Only individual software works

When running in Google Chrome, this script can be passed
But obsidian can’t pass, I don’t know why
It doesn’t work in Craft either

tell application "Hook"
	set note_bookmark to (bookmark from active window)
	set fileName to name of note_bookmark
end tell

Can someone help me with that

we’ll have a look. A commonality is the scripts involve x-callback-url.

What about this problem?

We can confirm there’s an issue with automation for x-callback-url based apps. We’ll have a fix.

1 Like

@LucB Have you made any progress

Yes. we understand the cause of the issue and how to solve it. The solution won’t be in Hook 3.6 unfortunately.

@LucB When will it be resolved

we currently plan to address in 3.7 or 3.8. No specific dates for those. Next up is 3.6.1 which will fine tune the menu bar icon status indicator.

Please add the number of hook link in the menu bar. There are Xbar script for that

2 Likes

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

Welcome to the Hook Productivity Forum , @amornj. And thanks for your feature request. This feature will likely be in Hook 3.6.1.

This is fixed in Hook 3.7 BETA available now.

@LucB

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

release 3.7 still doesn’t work for me

@meta, we needed to document the AppleScript.

Here’s some documentation:


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 : a bookmark


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.

1 Like

Has the problem been solved @LucB

1 Like

This now works with x-callback-url apps, as of the prior beta, carried into 3.8 official release.

Running the above script often fails

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

Agenda app, Drafts app, Obsidian app and Bear app all use x-callback-url.