Opening exactly the same window

Is there a way to open another window at the location (group) where I am currently working?

I know that there is a scrip to open the same file in two separate windows, but I am looking for something different.

Usually I find myself working on a file, and I go back and forth between other files in the same or nearby groups. At some point, however, it becomes a bit to cumbersome, and I open another window (File > New Window > database) and then I have a few more steps to find the exact group. Is there a way (a script?) that will allow me to skip all these steps?

Only by using a script, here’s a very basic example how to do this:

tell application id "DNtp"
	set theRoot to root of viewer window 1
	open window for record theRoot force yes
end tell
1 Like

And, of course, you can put that script in the toolbar or assign it a shortcut :slight_smile:

Could you please remind me how to add this script? I always forget that part even though I have done it a couple of times. I can see how to open the script folder, but the files are .scpt, which I do not know how to create.

I have sort of given up on keyboard shortcuts because there is always some interference with another application, and some days they work, some days they don’t. Do you have a foolproof method for creating shortcuts?

And I just found out from another thread, from 2015, that there is a way to add a specific script to the tool bar! I am definitely going to try to do it.

1 Like

As someone who basically tries to do as much as possible using keyboard shortcuts, I can offer my biggest tip in this area: get the application KeyCue and use it to find out what shortcuts are defined in the software you use. Whenever I’m trying to define a new shortcut (typically using Keyboard Maestro), I start up KeyCue and press some modifier keys in DEVONthink to see a listing of what’s already defined using those modifier keys. A great thing about KeyCue is it will find the shortcuts defined not only by the application you’re currently running, but by Keyboard Maestro and the ones in your macOS System PreferencesKeyboardShortcuts panel.

FWIW, there are a lot of ways to trigger KeyCue, and I personally find most get in my way, so I reduced it to the set shown below.


Thank you! Bookmarked. I will give this a try.

1 Like

Help > Documentation > Automation > Toolbar Scripts

1 Like

I was able to add one of the scripts I like to the toolbar. It works great.

I still do not know how to add the script for opening the same window.

I tried it by using ScriptEditor, but it opens a very different window setup. I tried choosing once a replicated file and also a non-replicated one. In either case, the second window that opens is very different. Any suggestions on how to solve this? I really know nothing about scripts, and appreciate the help very much.

The settings of windows are independent, the script opens only the group shown in a second window.

If you select two files then choose Script menu > Edit > Open in two windows, it should open each document in its own window, side-by-side.

This script will also open the same file in two windows.

If you don’t have that script available, install it from the Scripts section of the View > Extras sidebar or via Script menu > More Scripts and install it from the Support Assistant.

PS: There seems to be a bug with window bounds on M1 Macs, which I am looking into. Thanks for your patience and understanding.

I tried the script “Open in two window.” I do not know why I have three versions of it, but I tried them all. They work well, but they do not do what I want them to do. They work the same way as if I were to use the menu Edit > Open which is having the same file open in two external windows.

Instead what I want is File > New Window > Database Name > specific file and where it’s located. I am attaching a screen shot from a test database. The script that someone sent earlier opens a new database window but does not open to the exact file location. May be there is a bug? Or perhaps it depends on the file type? I tried different kinds of files, but it leads me to an unpredictable file location.

Screen Shot 2021-08-04 at 3.32.57 PM

You should select Script menu > Open Scripts Folder, then go into the Menu > Edit folder and remove any extraneous copies of the script. I would actually suggest removing all three then reinstalling it from the Extras sidebar or Help > Support Assistant.

The script will not open and display a file (or files) in a main window.
It opens document windows for the file(s) as is clearly shown in my screen captures.

I deleted the extra copies of the script, installed the script again, and it still does what you are saying it should not be doing: it opens two document windows (not database windows) side by side. I am attaching a screenshot of the result I get after I use the script.

The script that someone else posted earlier does open database windows (like in your screenshot), but the problem is that they are at random locations.

That’s not what I’m said. That’s what it’s supposed to do: open two document windows side-by-side.

1 Like

No, you got it wrong. The script is doing what it should do. Jim wrote:

This script duplicates the first main window (viewer window).

Note: Because there’s no root we could use to duplicate the window the script throws an error in any of these cases:

  • if there’s more that one group selected in the navigation sidebar
  • if the window’s root is a Smart Rule
  • if the window’s root is a global Smart Group
  • if the window’s root is the trash container group
-- Duplicate viewer window

tell application id "DNtp"
		if not (exists viewer window 1) then error "Please open a viewer window"
		set theWindow to viewer window 1
			set theRoot to root of theWindow
			set theRoot to theRoot
		on error
			error "This script doesn't work with a multiple sidebar selection, a global Smart Group or a Smart Rule"
		end try
		set theSelection to selected records of theWindow
		set theBounds to bounds of theWindow
		set theBounds_cascaded to {(item 1 of theBounds) + 22, (item 2 of theBounds) + 22, ((item 3 of theBounds) + 22), (item 4 of theBounds) + 22}
		set theNewWindow to open window for record theRoot with force
		set selection of theNewWindow to theSelection
		set bounds of theNewWindow to theBounds_cascaded
	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
  • Open Script (e.g. via Spotlight)
  • Paste the script
  • Save as scpt file
1 Like

Belated thank you! The script works.


Pete31, just here to say thank you again because I use this script ALL THE TIME. Happy holidays!

1 Like

Thanks for letting me know :slight_smile: Happy holidays!

1 Like