Curio 13 "Get Adress" Script for items in a project

Using Hook out of the box with Curio one can only “hook” the full curio file, not specific Idea Spaces or even individual items.
On the other hand, there is a “Copy as Hyperlink” function that seems to get hyperlinks out of pretty much any object in Curio …

So I’ve put together items from a few sources (namely, a first scripting attempt from the the Curio forum and the “Drafts” script that comes with Hook, to get this:

set the clipboard to ""
delay 0.1
tell application "System Events" to tell process "Curio"
	# get url
	click menu item "Hyperlink" of menu 1 of menu item "Copy As" of menu 1 of menu bar item "Edit" of menu bar 1
	repeat 10 times
		try
			set myUrl to (the clipboard)
			if myUrl is not equal to "" then
				exit repeat
			end if
		end try
		delay 0.1
	end repeat
	#get title
	set the clipboard to ""
	delay 0.1
	try
		click menu item "Plain Text" of menu 1 of menu item "Copy As" of menu 1 of menu bar item "Edit" of menu bar 1
		repeat 10 times
			try
				set myText to (the clipboard)
				if myText is not equal to "" then
					exit repeat
				end if
			end try
			delay 0.1
		end repeat
		set n to count of paragraphs of myText
		if n is equal to 0 then
			set firstLine to name of front window
		else
			set firstLine to item 1 of paragraphs of myText
			set len to the length of firstLine
			if (len > 256) then
				set firstLine to text 1 thru 255 of firstLine
			end if
		end if
	end try
	return "[" & firstline & "](" & myUrl &")"
end tell

This goes in the “Get Adress” script tab of a new Curio script-set that I created for the occasion.
It will output a hook for either:

  • an Idea Space (in which case it gets the name from the name of the window, don’t know how to get anything more precise)
  • any selected item IN an Idea Space (in which case the name, as per the Drafts script, is made up of the first 256 caracters of the content)

This is plainly a first attempt which will likely break (as I’m typing, I’m thinking “image with no text”) so please help if you have any ideas how to make this better.

On a side note, I’m surprised at Curio’s classification in the “Apps that work with Hook” list as having “reliable automation”. I can’t find a way to address Curio through scripting, other than my kludgy GUI script.

Thanks for contributing your scripts and experience, @seishonagon . It’s very helpful to get feedback from the community on particular apps.

Our internal notes on Curio date back from 2017, where a couple of us tried Curio with Hook. We internally noted works with Hook’s defaults, no script required. There’s a prior entry on the forum from last year that in the context of Curio, Hook works only with entire Curio documents, not more precise than that. I have now added a qualification to the Curio entry on the linkable apps page that:

(Links are to entire documents not spaces.)

At the moment, Hook doesn’t systematically do deep linking to the internals of documents. I’ll add a more general note about deep linking on that the Linkable Apps page. I’ll need to better understand Curio , and listen to the community, to better understand what the current lack of deep linking entails for Hook with Curio. Deep linking is something we want to support systematically.

@LucB, understood re the classification, and thanks for the note.
When you review Curio, you’ll see it’s not really useful to link to the entire document: it’s a little bit like linking to an entire .tbx file, rather than an individual note inside the document.
Luckily Curio has an internal mechanism to address individual notes, so we can latch onto that. I’ll try to make inquiries with the dev to see if it’s accessible through other means than gui scripting …

1 Like

AAAAAnd … it’s broken.
Hook now doesn’t seem to run the “Get Address” script, it just returns a “file:///” protocol address with the name of the Curio Window. It’s not even a real file in the system!
I don’t think i’ve done anything to either Curio or Hook to warrant this! Reinstalling hook doesn’t help.

FYI, as a stop gap: You can use the Hook to Copied Link command with any URL in the copy buffer. The URL does not need to come from Hook. Examples:

  • OmniFocus has a Copy Link command. You can use OmniFocus’s Copy Link command on a task and then Hook to Copied Link elsewhere.
  • in a web browser, you can copy an address from the address bar, or from a link, and then feed that into Hook to Copied Link
  • you could get a link from Curio to a specfic object, and use it in Hook to Copied Link.

For the title to appear, you can copy a Markdown style link. e.g., if you were to copy [Some title](https://discourse.hookproductivity.com/t/curio-13-get-adress-script-for-items-in-a-project/1443/3) then you could use that in Hook to Copied Link elsewhere. The next step is for it to be done programmatically. We’ll look at Curio again.

in what context? The URL’s that are returned are a function of the context (typically the app). For many apps, Hook has a script in Hook’s Preferences > Scripts tab. If you edit a script, it can break the Copy Link function for the corresponding app. You can easily revert scripts by clicking on the “-” button at the bottom of the left column, :


in the example above, I’ve edited the DEVONthink 3 script, so a * shows up to the right of the script name.
I can click the “-” button to revert the script.

I’m new to Hook although it seems I have a number of Curio customers using Hook to tie Curio to DEVONthink and many other apps. Very exciting!

Yes, Curio’s Edit > Copy As > Hyperlink menu item will return a curio:// hyperlink to the selected figure (on the current idea space, within the current project). But obviously that requires UI scripting which isn’t very graceful.

I’m diving into the Hook integration docs right now. If I were to add an AppleScript command to the upcoming Curio 14 to return a markdown formatted link to the selected figure would that help?

1 Like

I have added at the beginning of your code the following

tell application "Curio"
activate
end tell

and it is working fine for me now!

Thank you very much for your script!

2 Likes

that would be great, @georgezengobi. We would add Curio to the built in scripts to deal with that. If it returns a value, Hook’s Copy Link command would use it. Otherwise, Copy Link would fall back on the overall document URL. (A CogSci Apps dev might have some other ideas to add.)

A quick rough draft that I just got working in-house:

tell application "Curio"
	external hyperlink as markdown of selected figure of active document
end tell

Selecting a figure in Curio and running that script returns this string:

[Curio project \"Pepsi Campaign\" > \"2020 Plans\"](curio://$Projects/Pepsi%20Campaign.curio?i=hVStpJFZRyOG1-qc5bIs_Q&f=iUuzRZ7dQ3OeqrXja5flug)

Thus the link name is:
Curio project "Pepsi Campaign" > "2020 Plans"

And the direct URL to that figure:
curio://$Projects/Pepsi%20Campaign.curio?i=hVStpJFZRyOG1-qc5bIs_Q&f=iUuzRZ7dQ3OeqrXja5flug

Can you work with something like that?

1 Like

We’ve just tried the support you provided and it works very well. Super!

1 Like

You’re right. It work … except if I set the delays to zero, so it’s probably a problem of the GUI scripting going too fast wrt the apps.
Well, while the devs figure it out between themselves, we have a working solution!
Thanks for the help!

Thanks for the pointers, @LucB, but I think it’s simply a classic example of why you don’t want to GUI script if you can avoid it … adding the activation line at the top seems to stabilize it.

yep. UI scripting is brittle. to be more precise, I should have quoted this text:

and said “perfect”.

@georgezengobi’s has released Curio 14.. It has lots of great features, including the AppleScript we need to get the name and URL of items inside Curio documents.

So with version 117 of Hook integration scripts, Hook now supports deep linking to Curio, as described in Hook’s release notes section of this forum.

Thank you and congratulations @georgezengobi !

2 Likes

Yeah, it’s everything I wanted! Thanks to @LucB and @georgezengobi for jumping on this thing so quickly.

3 Likes