AppleScript to open specific item in DTP

I have created a formatted note (‘Competition law’) in a sub-directory of the main Inbox (To read).

From outside of DevonThink Pro I would like, with AppleScript, to open that note (that is to see the contents of the note in DTP).

Is the ‘get record with uuid’ command in AppleScript the right command to use? And how do I find the uuid of an item?

What would the correct syntax of the AppleScript command?

This is the correct command but where exactly do you want to use this script? Maybe an item link (see Edit > Copy Item Link) is already sufficient to open the document in DEVONthink.

Thank you for the reply. I am familiar (and use) the item link all the time.

Once I have created the AppleScript I will assign it to a shortcut key. The reason is that the particular contains document has a lot of links to other documents in DTP.

I frequently need to refer to this document from a range of other apps (Word, Safari, Notes, HoudahSpot). So having a shortcut key where I can invoke the particular document is what I would like to do. Also I am trying to learn AppleScript, so knowing the correct syntax will be helpful (a search on the DT forum or elsewhere did not reveal any examples). For example, how to find the uuid of an item.

I would be grateful for any further help.

The script could look like this:

property pUUID : "insert UUID here"

tell application id "DNtp"
    set theDoc to get record with UUID pUUID
    open window for record theDoc
end

To get the UUID you could e.g. use the URL copied via Edit > Copy Item Link. The UUID is everything after x-devonthink-item://

2 Likes

Note: You can’t just assign a hotkey to a script. You’d need to use some global option or utility to create this behavior.

Thank you cgruenberg and bluefrog for the replies.

The code does just what I need.

Regarding the shortcut key: I will be using Keyboard Maestro to deal with that.

The best option for me in the situation you described - is Keyboard Maestro.

Yet other methods for fast navigation:

  1. Create a little Markdown file with all the needed links, which you use often, and place it somewhere at hand. It’s like Favourits - clicking the link will open the file or group. I recommend to add “?reveal=1” to the end of UUIDs in this file
  2. Call one of the Labels “Bookmarks”. Make the Smart Group like “Favourites” (searching for files and groups with this label). Then label and unlabel your most used items as you work and you’ll always find them in your Favourites group. This is the best option I use now, because it retains the look of this smart group (particularly the state of groups tree: collapsed and open groups) even if you collapse it and go work in other groups. It is important if you work actively with the groups structure (in Split view)

But what happens when you add

___Cmd-Ctrl-D

(or any other combination to the script file name?
When I do so, it does add a shortcut key to the script …

54

This is DEVONthink-specific, not a global hotkey. The OP wants to use a hotkey for a script in an application-agnostic fashion.

1 Like

Would be possible to JUST open the UUID while safari is in front? If so what do I need to add to the script?

For instance if Im on safari I would like to just open the UUID window.
(Currently it brings up the UUID and DevonThink)
Thanks.