AppleScript goto group?


is it possible to create a AppleScript to go directly to a group (via uuid?)

I found this bit this relates to specific inboxes and opens a new window (and not switch to a group I current window):

tell application id "DNtp"
	set inGroup to incoming group
	open window for record inGroup
end tell

I tried using KM do do this in a tacky way but the last part of the return docent seem to execute…



May I ask why you’re trying to go to a specific group?

PS: While a valiant effort, that kind of attempt to reproduce mechanical processes is fragile and fiddly. I don’t recommend it - and also avoid it in AppleScript as much as possible.

hi :slight_smile: well basically a quick mark browser like method of jumping quickly between different groups without touching the mouse. I know there are favorites and a goto command but they require 2-3 steps (…yeah I get lazy)



This should work, assuming there’s at least one main window currently visible:

tell application id "DNtp"
	set theRecord to get record with UUID "Insert-UUID-Here"
	set root of viewer window 1 to theRecord

thx that’s perfect @cgrunenberg!!



That’s great and very useful. Is there a way to do the same thing but to open the UUID in a new window?

Thank you.

Sure, see open window for command of DEVONthink’s AppleScript support.

Thank you, @cgrunenberg.

Previously, as suggested in other threads, I did open the directory for DTP in Script Editor, where I found ‘window’ and ‘viewer window.’ I tried multiple times to use syntax including ‘open window,’ ‘new window,’ ‘new viewer window,’ etc, but unfortunately my syntax must be failing. I did figure out how to open a window, but it only gives the contained elements in icon view, and its a window with no title bar, side bar or other elements of my standard DTP windows, and its size is quite different. Sorry, I don’t know what to call this window.

I am just not understanding how to open a new window just like my other DTP windows, and then direct it to the pertinent group. I am not sure what the window I am getting is called, or if there is a way to change its appearance to match my other windows.

Thank you.

It’s not clear to me what you’re trying to do.

Do you want to open a new “main” window (in DEVONthink AppleScript terminology viewer window) for a given group?

-- Open window for group

tell application id "DNtp"
		set theGroup to (get record with uuid "2B24C073-ACD0-4B29-981F-6A9C089CE9BE")
		set newWindow to open window for record theGroup
	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


That’s it!

Awesome script. I would never have figured it out myself.

It takes the renamed file, moves it to the correct group, and then activates DTP, opens a NEW window with that group.

Greatly appreciated!

1 Like