Method to open annotation file in new window

In DEVONthink, annotation files (not to be confused with other kinds of annotations, such as annotations in PDF files) are accessed via the Annotations & Reminders inspector panel.

Personally, I find that editing an annotation file is more conveniently done in a separate window instead of the little box in the inspector. I wanted to have a keyboard shortcut to quickly open an annotation file in a separate window, but it does not seem possible to target the “Open” command in that pull-down menu via macOS’s built-in shortcuts facility, nor have I been able to invoke it directly via Keyboard Maestro.

Thankfully, it is possible to write a short AppleScript program to tell DEVONthink to open the annotation file in a new window, and this in turn can be set up as an action in a utility such as Keyboard Maestro with a keyboard shortcut. Here is such a script:

tell application id "DNtp"
	try
		repeat with theRecord in (selection as list)
			if (exists annotation of theRecord) then
				set annot to get annotation of theRecord
				set annotRecord to get record with uuid (get uuid of annot)
				open window for record annotRecord with force
			else
				set rec_name to get name of theRecord
				display alert "Document has no annotation" message rec_name
			end if
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then
			display alert "DEVONthink" message error_message as warning
		end if
	end try
end tell

(The code is also available from one of my GitHub repositories.) The script will handle multiple selections, and open each annotation file in a separate window. It will show a warning dialog if a document does not have an annotation file associated with it.

Maybe this will be useful to other people too. (And if there is a better way, I’d be happy to hear about it.)

6 Likes

The next release will add the default shortcut Cmd-Ctrl-Alt-O to the Open menu item.

3 Likes

I use bettertouchtool for these kinds of challenges. You can open context menu items by name or number with it. Works great. (I use it to merge files for example. Something that no other tool can create a shortcut for as it is changing it’s name depending on how many items are selected)

1 Like

thank you very much for the script. This is just what I need!

1 Like