What is the AppleScript command to open a document in its default app?

In some AppleScript code I’m writing, I want to open a selected DEVONthink document in its default app in the same way that the default o does. What is the correct AppleScript command for that?

I always tell Finder to open the file; I’m not sure whether there is a more direct way, though.

1 Like

https://discussions.apple.com/thread/7761153

tell application "System Events" to keystroke "o" using {command down, shift down}

That’s the recommended way as both DEVONthink & the Finder use the same system settings.

Obviously, you can do that, but surely there’s a more direct …

… okay, never mind then, I guess there isn’t a more direct way :slight_smile:

more direct than telling finder to open it? Given that Finder is the app that knows about the program(s) able to open files, it is hard to imagine how you would go about without it. You could of course use @DTLow’s suggestion of sending keystrokes, but if that qualifies as “more direct” might be a matter of discussion. Also, I suppose that this Shift-Cmd-O thingy will simply be translated into the corresponding finder action in DT.

Oh, and then there’s this:

https://developer.apple.com/documentation/appkit/nsworkspace/1533463-openurl?language=objc

which you can use in AppleScript (with the help of its ObjC bridge), but I think that’s even more convoluted.

1 Like