Double click and open with default...

I notice in DT (Mac) in some places has double click as open with the default application, and in other places open with the DT viewer. Is it possible to always have double click open with default?

No, this is not possible (and has been discussed at length here).
Check this out: Tuesday Tip: Editing options in DEVONthink

Thanks Bluefrog. It’s a shame it can’t be changed - a simple option is all it would take to suit both workflows instead of a “most people wanted this” approach.

Actually, it’s not so simple an option as the preference would likely be very situational. There are many times someone would want to use the default app when double-clicking, then times when they’d want to open it in DEVONthink. This is why the current option is in place, as well as providing the Open With menu.

Yes, but the default is learning towards a certain workflow. Most other apps have an option to choose one lean or another lean. That’s what options are for!

It’s just a simple reversing of the workflow. It’s not hard to implement. And, after using thousands of software programs it’d certainly help someone like me who double clicks on things to open in the app, because that’s the default behaviour in the OS and every app that follows suit.

Let’s beat this dead horse a bit, shall we? :slight_smile:

I know it’s been stated that the majority of users prefer the current behavior, but in case anyone is still counting votes, I would (very much) prefer that double-clicking would open documents in their default applications. It’s not “situational” for me. I never want to open documents for editing inside DEVONthink. Count me as part of the “I would really like an option for this behavior” camp.

I understand and agree with the argument against adding preferences willy-nilly. However, at some point the pressure to add an option might justify a small amount of additional complexity.

There are compromises I’d make in order to have the “Open in Default Application” preference. For example, I personally could live without the following existing preferences:

  • Import->iChat & Yahoo! Messenter logs (still relevant?)
  • Media->Play Movies [Automatically | Loop] (does a majority want this option?)
  • Media->Markdown [Edit documents | Preview documents] (also already has easy keyboard access)

And what about a “Hidden” preference? Or do those add too much to the support burden?

Anyway, I know this request is likely already considered “Closed, Won’t Fix” but I’ve been using DEVONthink for years and still haven’t trained myself to not double-click files when I want to open them in their default applications.

Nearly all of my surprise reactions to DEVONthink’s behavior are, “Wow, cool! I didn’t know it could do that!”. The double-click behavior might be the only thing about DT that causes me undue friction multiple times every day.

Thanks for listening.

Jack

2 Likes

You’re absolutely right here that different people have different workflows. And even though we have discussed this already at length in the past and settled for one way, this is not hammered into stone. So we might offer an option here (even though we strongly try to not add more options and fall into the featuritis trap) in a future version. At least it’s on our “(re)consider list”.

Great to hear that!

Thank you. Your willingness to take another look at it is much appreciated. If it turns out that you continue to feel it adds more complexity than it’s worth, then so be it :slight_smile:.

Jack

One of my main uses for DTPO is to maintain permanent links within scientific notebooks, and the current behavior of DT causes some friction.

I document scientific processes in the lab with, for example, textedit (rtfd), and within those notes are links to other notes. So my notes page will have lots of links like x-devonthink-item://46E…350. Because I keep all my lab notes (and my students’ notes) indexed within DT, we get the huge benefit that the links don’t break if I ever move/rename things. The downside of DT’s current behavior of opening docs within DT is that when we click on a link to another file, it opens in within DT rather than within Textedit. That’s not ideal, since we really want to use Textedit for its ability to deal with embedded images etc. So, each time we click a link to another note, we then have to do a cmd-shift-O to open another copy of the note within textedit. Then to reduce clutter we go back to DT and close the doc within DT, and then switch back to Textedit to edit the linked note. Not a big deal to do once, but more so to do 100 times a day. Is there an equivalent to cmd-shift-O that I can use with a link to tell DT that the link I’m clicking on should be opened with the default app rather than DT?
Thank you for any thoughts on this,

Carl

P.S. The problem is even more of an issue if, say we open a main note that links to 10 other notes that we need to have open for editing. If we click on those 10 links, now we have 10 DT docs open. We then have to go through each DT doc and do a cmd-shift-O to open them in textedit. But there’s no good way to know which of the 10 you’ve already done cmd-shift-O to, and so you have to move each one to a new window so you can keep track of which ones you’ve already reopened in the correct app.

I recently wrote a script that looks up and opens links. It opens them in DEVONthink, so I made a version for you. Select your link(s), or the whole page, run the script and it will open them in the default app.

It uses macOS System Events to copy selected text so it may be that you have to increase the delay if you use it via shortcut (e.g. via Alfred or Keyboard Maestro) as there’s a chance that once in a while you don’t let your triggering shortcut go fast enough which will let macOS register your shortcut plus the shortcut System Events presses. However waiting 0.5 (or more) seconds should be no problem if you don’t have to open and close all those DEVONthink windows. If you use it via DEVONthink’s menu or toolbar that’s of course no issue.

-- Open selected text's link(s) in default app

property theDelay : 0.5

tell application id "DNtp"
	try
		set theWindow to think window 1
		try
			set selectedText to selected text of theWindow & "" as string
			delay theDelay
			activate
			tell application "System Events" to tell process "DEVONthink 3" to keystroke "c" using {command down}
			try
				set theGrepResults to do shell script "osascript -e 'the clipboard as «class RTF »' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))' | egrep -o 'x-devonthink-item[^\"]*'" -- https://superuser.com/a/1409995/
			on error
				display alert "No link(s) found" buttons {"Ok"} default button 1 message "" as critical
				return
			end try
			set theRefURLs to paragraphs of theGrepResults
		on error
			display alert "No text selected" buttons {"Ok"} default button 1 message "" as critical
			return
		end try
		
		repeat with thisRefURL in theRefURLs
			set thisPath to path of (get record with uuid ((characters 21 thru -1 in thisRefURL) as string))
			tell application "Finder" to open file (POSIX file thisPath as alias)
		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 try
end tell

Wow! that’s an unbelievably quick reply. I’m not a scripting expert, but I think I know enough to give this a try. Thank you very much for taking the time to post this!!

So I dropped it into Alfred w/ a shortcut of “dtod”, selected the DT link within textedit, and ran the script. Unfortunately, no joy. I turned on debugging within Alfred and get the following error (which is already past my scripting expertise). I did also try selecting the link within DT to see if that helped, but got the same result. Apologies if it’s an obvious mistake I’m making here.

[16:44:46.062] Logging Started…

[16:45:00.204] DT (open in default) (dtod)[Keyword] Processing complete

[16:45:00.211] DT (open in default) (dtod)[Keyword] Passing output ‘’ to Run NSAppleScript

[16:45:00.211] ERROR: DT (open in default) (dtod)[Run NSAppleScript] {

NSAppleScriptErrorBriefMessage = “Expected \U201cend\U201d but found \U201cproperty\U201d.”;

NSAppleScriptErrorMessage = “Expected \U201cend\U201d but found \U201cproperty\U201d.”;

NSAppleScriptErrorNumber = “-2741”;

NSAppleScriptErrorRange = “NSRange: {70, 8}”;

}

Sorry, wrote it for usage in DEVONthink. It should be no problem to change it so that it works in any app, but I’m running a backup right now. After that I’ll change it

I did get your original script to run from within DT. I could not however get the new version to run even from within DT. Thank you for looking at this error.

This version should work from within any app. Tested with TextEdit, Nisus Writer and TextSoap.

-- Open selected text's link(s) in default app

property theDelay : 0.5

try
	delay theDelay
	tell application "System Events" to tell (first process whose frontmost is true) to keystroke "c" using {command down}
	set theGrepResults to do shell script "osascript -e 'the clipboard as «class RTF »' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))' | egrep -o 'x-devonthink-item[^\"]*'" -- https://superuser.com/a/1409995/
on error
	display alert "No text selected or no link(s) found" buttons {"Ok"} default button 1 message "" as critical
	return
end try

tell application id "DNtp"
	try
		set theRefURLs to paragraphs of theGrepResults
		
		repeat with thisRefURL in theRefURLs
			set thisUUID to (characters 21 thru -1 in thisRefURL) as string
			set thisRecord to get record with uuid thisUUID
			set thisPath to path of thisRecord
			tell application "Finder" to open file (POSIX file thisPath as alias)
		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 try
end tell

There are two AppleScript actions in Alfred, the one you need here is

1

then in this action’s first dropdown

2

Replace the example code with the script and it should work.

This partially works for me. After it correctly opens the file corresponding to the link in the default app, DT throws an error: “Can’t get path of missing value.” So if a single file is selected, then the file will open correctly, and then one needs to go to DT and click “ok” on the error dialog. This wouldn’t be that much of an issue except that it seems to interrupt the script. So if you’ve selected several files, the first will open, then you click “ok”, and that causes the script to exit.

Even as is, the script is an improvement over the vanilla DT functioning here, but a script that just looks through a selection for links and opens them all in default apps really would be a brilliant addition to my lab’s workflow. So if you have time for any further thoughts, they will be greatly appreciated.

Alfred debug shows the following if I run it with one link in the selection:
[21:40:12.019] DT (open in default) (dtod)[Keyword] Processing complete
[21:40:12.025] DT (open in default) (dtod)[Keyword] Passing output ‘’ to Run Script

So that seems consistent with it running correctly with the link in the selection, but then passing it a blank. I’ve tried to make sure I’m not passing any arguments to the script within alfred, and that it isn’t expecting an argument. Beyond that, I’m not sure why it’s getting a null input.

Hm, it’s working fine over here

I could add a try block, but you should not get any errors with the current version. Don’t know what it might be.

No that’s not causing the error, my debug looks the same after opening more than one link.

[03:49:14.904] TEST - ausgewählte Links in Standard App öffnen[Keyword] Processing complete
[03:49:14.906] TEST - ausgewählte Links in Standard App öffnen[Keyword] Passing output '' to Run Script

Seems DEVONthink couldn’t get the record but I have no idea why. I would understand an error from Finder like “can’t get path” if one selected a link to a smart group, as those have no path, but I’ve never seen DEVONthink not getting a record.

Don’t know how to solve that other than adding a try block.

-- Open selected text's link(s) in default app

property theDelay : 0.5

try
	delay theDelay
	tell application "System Events" to tell (first process whose frontmost is true) to keystroke "c" using {command down}
	set theGrepResults to do shell script "osascript -e 'the clipboard as «class RTF »' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))' | egrep -o 'x-devonthink-item[^\"]*'" -- https://superuser.com/a/1409995/
on error
	display alert "No text selected or no link(s) found" buttons {"Ok"} default button 1 message "" as critical
	return
end try

tell application id "DNtp"
	try
		set theRefURLs to paragraphs of theGrepResults
		
		repeat with thisRefURL in theRefURLs
			try
				set thisUUID to (characters 21 thru -1 in thisRefURL) as string
				set thisRecord to get record with uuid thisUUID
				set thisPath to path of thisRecord
				tell application "Finder" to open file (POSIX file thisPath as alias)
			end try
		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 try
end tell