Applescript to create new hook on active object and set to clipboar

Hello, my applescript knowledge is poor and I can’t find a working example of doing this… I just need to get Hookmark to create a hook on the active document/website/etc. And set that to the clipboard. If it can be done without hookmark flashing up.

This is my attempt, but it doesn’t work:

Thanks for your help

1 Like

Thank you for contacting us, @s32 .

Here is a sample script you can try:


tell application "Hookmark"
	
	set theResult to bookmark from active window
	
	if class of theResult is not bookmark then
		
		delay 1
		
		set theBookmark to bookmark by request handle theResult
		-- you can get address, path, name from a bookmark
	end if
	set addr to address of theResult
	set the clipboard to addr
end tell

Thank you

That’s perfect. Is there an easy way to amend it to return a markdown link?

Worked out a solution. I needed to pass the variables off to keyboard maestro, so I’ve just tweaked you script to support that. Thanks for your help.

1 Like

Wow, this is a great request and thanks for the solution.

I am an AppleScript dummy - please forgive :wink:
How do I package the script above in a container and how do I run it then.

Many thanks in advance,

Best,
Frank

Hi Frank,

I run it using keyboard maestro - the app referenced in the final paragraph - which can receive variables. KM then sets those variables to clipboard with a few extra bits around the text, and passes it to shortcuts to append to a Drafts document.

But, you could also launch the script through Shortcuts or FastScripts, but I’m not familiar with passing variables from AppleScript onto them. If you haven’t used it yet, keyboard maestro is excellent. It’s like the glue that holds all my automations together.