Open annotation file with keyboard shortcut even when inspectors pane is hidden

I usually open the annotation file for a document with the shortcut Cmd-Ctrl-Alt-O. But this does work only if the inspectors pane is visible. It would be nice if I could open the annotation file with that shortcut even when the inspectors pane is hidden.

Why don’t you install and use the Open in two windows script from the Script menu > More Scripts? If a selected document has an annotation file, it will be opened in a document window with the annotation file in a document window next to it.

because I really want to open only the annotation file in another window. I solved this now by using the script on Open annotation file with keyboard shortcut even when inspectors pane is hidden in combination with Keyboard Maestro. That does exactly what I need.

The link above accidentally goes to this thread instead of the one intended, which I take it was this one:

2 Likes

That script is super helpful! I changed it a tad and thought I’d share. I like to use Typora as my markdown editor, so I made the script open the annotation file in Typora if there was an annotation file. Also, I don’t use keyboardmaestro so I put the script in the scripts folder and used the app CustomShortcuts to give it a keyboard shortcut. Now whenever I have a record selected in DT and hit the keybinding it opens the annotation file in Typora. Super awesome!

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)
				set thisPath to path of annotRecord
				do shell script "open -a typora " & quoted form of thisPath	
			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
2 Likes

That should work fine, but as a tip, the use of a shell command can be avoided by using the direct AppleScript approach like this:

tell application "Typora" to open thisPath

This approach should also avoid potential problems when the file name or path has special characters in it (which is something that can cause problems when strings are constructed and executed as shell scripts, even when using the “quoted form”).

2 Likes