Switch current group using AppleScript?

When I move a new document from the Inbox of a database to its final folder (using ⌃⌘M), I often switch to that folder (using ⌘L) to check for missing tags, related documents, etc.

When I want to process the next document, I have to use the mouse/trackpad to navigate back to the Inbox folder. Ideally I would like ⌘L to toggle between the source and destination folders of a moved document instead of just jumping to the destination, but that would be an enhancement request.

To get something working right away I tried to use AppleScript bound to a different key. Unfortunately I can’t get it to work:

tell application "DEVONthink 3"
	set theInbox to parent "Inbox" of current database
	set current group to theInbox
end tell

The assignment to current group doesn’t seem to be allowed. Is there a different way to achieve this?

I do same, but I do all my “manual in-processing” using the “Today” Smart Group. Even when the document is moved into a new group it remains in that view for me to do as you describe. No scripts in play, other than a few Smart Rules processing some documents arriving in the Inbox, of course. Even those show up in the “Today” smart rule view for any hand-tweaking or immediate reading.

3 Likes

The shortcut of Go > Back should be a faster option.

1 Like

I use an Applescript to process Inbox entries; assigning name, tags …
including moving the record to it’s final folder (theFilingGroup)
The final statement of the script is open window for record theFilingGroup
so I can “check for missing tags, related documents, etc.”
When I close that window, I’m back to the Inbox window

1 Like

As the scripting dictionary says:

currentGroup (Record, r/o) : The (selected) group of the frontmost window of the current database. Returns root of current database if no current group exists.

The “r/o” stands for read-only.

But the root of viewer window can be changed, that’s like selecting a group in the sidebar.

Thank you! That is exactly what I needed (⌘[).

By the way, a long click on the < and > buttons in the Path bar opens a popup to choose one of the last locations.

1 Like

Oh goodness…how one lives and learns! Thank you.

Stephen

Sorry for resurrecting old threads, but I still can’t work out how this works. (If only AppleScript dictionaries had code examples…)

With this code

tell application id "DNtp"
	set theInbox to parent "Inbox" of current database
	set root of viewer window to theInbox
end tell

I get Can’t set «class DTro» of «class brws» to «class DTpr» id 9 of «class DTkb» id 2 of application "DEVONthink 3". which doesn’t really mean a lot, especially since the dictionary doesn’t seem to map these four-letter class names to the actual English names of classes.

Does anybody have some example code that will set the current viewer window to the global inbox? I really don’t want to have to add it as a Favourite¹ and then have Keyboard Maestro navigate to that through the menu.

¹ If people using en_GB have to suffer the Trash being called the Bin, it would be lovely if Favourites could be spelt correctly, with the letter U, rather than in the American way :grin:

The code makes no sense – what is "Inbox" of current database supposed to be? The thread started, btw, with someone posting this code and stating that it doesn’t work. So little surprise here.

There is a global inbox, which is a database by itself. So, not even inbox of current database makes sense.

Interestingly, when I run the code you posted, I do not get the same error as you. But if I run

tell application id "DNtp"
	set theInbox to incoming group of current database
	set root of viewer window to theInbox
end tell

the error is indeed similar to what you posted. Weird.

@cgrunenberg: If I run this snippet, where is current group involved? The error occurs on set root of viewer window to theInbox, btw.

error “„«class DTro» of «class brws»“ kann nicht als „«class DTpr» id 9 of «class DTkb» id 9 of application "DEVONthink 3"“ gesetzt werden.” number -10006 from «class DTro» of «class brws»

Perhaps root of viewer window is read-only, too (the documentation doesn’t say so, though)

What are you specifically trying to accomplish by changing what’s viewed ?

I really don’t want to have to add it as a Favourite¹ and then have Keyboard Maestro navigate to that through the menu.

Why would you have to use Keyboard Maestro for this when you can already set application-specific hotkeys in System Preferences > Keyboard ?

1 Like

Which version of macOS do you use? I’m experiencing some weird AppleScript issues on the betas of macOS 15.4 lately.

At least I’m still running 15.3.2, and I see the error I quoted above.

This

tell application id "DNtp"
  set root of viewer window 1 to incoming group of current database
end tell

works flawlessly. Apparently, the app wants an index with a viewer window. Which is kind of understandable, since there could be more than one of those windows.

2 Likes

The answer to both of these questions is that I want to assign a key on a Stream Deck profile for DT3 to switch to the global inbox — so the system keyboard preferences don’t really help.

@cgrunenberg macOS 14.7.4 — I keep hoping that Apple will release a version of Sequoia where somebody doesn’t immediately find something that stops me upgrading, but it hasn’t happened yet :slight_smile:

@chrillek viewer window 1 was the key — and omitting the of current database gets me the global inbox. Thanks!

The answer to both of these questions is that I want to assign a key on a Stream Deck profile for DT3 to switch to the global inbox — so the system keyboard preferences don’t really help.

You don’t need a script to do this with the Stream Deck.

Just use the Global Inbox’s item link with a ?reveal=1 parameter and add it as a URL to a Stream Deck button. And you can do that with any other item in your databases as well.

4 Likes

Item links… I knew I was forgetting something :man_facepalming:

Thanks!

1 Like