Running macOS 15.4.1, I use a short Alfred workflow to launch DEVONthink. It is simply a keyboard shortcut linked to the following AppleScript:
tell application id "DNtp"
activate
load workspace "Diaries"
end tell
If I load the “Diaries” workspace within DEVONthink (i.e., when it is already running) it correctly shows “Smart Rules” and “Smart Groups” collapsed in the navigation sidebar. However, when it is run via the code I have mentioned it shows those expanded. Further, on each occasion it does so it adds an identically named workspace to the list under DEVONthink → Window:
The same thing happens if I run the script from Script Editor. (The identically named workspace is not added if I load the workspace within DEVONthink.)
I’m rather at a loss as to why that happens so helpful comments are welcome!
The load workspace command doesn’t automatically close windows, therefore new windows having new settings are used in this case. See e.g. Open Clean Workspace… script available via the Help > Support Assistant how to avoid this.
It’s not a new workspace, just a new window. See above.
Thanks for the prompt reply and explanation. I have tried using the script you mentioned but it invariably seems to leave me with a number of DT windows (through which I can move using CMD + backtick). In other words the AppleScript command close every window appears not to have the desired effect. (I wonder whether it’s a timing issue?)
At present the best workaround for me is what I previously used: to ensure I quit DT in the form I’d like it to launch. That is no hardship so please don’t devote time to this small problem!
Sorry, first I should have said that your latest suggestion was an improvement—in that I had only one additional window open. I did not mean to sound unappreciative!
Um…er…it’s pretty much a duplicate of the window I want:
For what it’s worth, I created an entirely new workspace, using another database, and the result of running your script using that workspace is the same in terms of open windows: there are two.
tell application id "DNtp"
activate
close every think window
delay 2
with timeout of 3600 seconds
close every database -- There is the potential this may not close a database if it's actively syncing.
end timeout
load workspace "Diaries"
end tell
running from Script Editor still gives me two windows—one “Inbox” and the other the requisite “Diaries - 2025” window. If I remove the Delay command I end up with two identical “Diaries - 2025” windows.