Show or hide the sidebar using AppleScript

I want an AppleScript to open a new window, to set its bound and to hide its sidebar at the left.

Unfortunately, I do not know how to achieve the latest task. The best I could do is the following script, which simulates the keyboard shortcut to toggle the sidebar. This is unsatisfactory as it hides the sidebar only if it was previously shown.

tell application "DEVONthink 3"
	set w to open window for record (record 1 of database 1)
	set bounds of w to {0, 0, 1000, 1400}
	tell application "System Events"
		activate application "DEVONthink 3"
		keystroke "1" using {command down, option down, shift down}
	end tell
end tell

When I search DEVONthink’s AppleScript dictionary, it seems that no entry includes the term “sidebar”. Nevertheless, is there still a way to control through AppleScript a window’s sidebar ? Thanks. W.

No there is no command or property for toggling the sidebar.

But there’s a request for that, isn’t it?

That would be Criss’ territory.

The user interface isn’t scriptable, maybe in the future it will be but no such plans in the near future at least.

It will certainly be fun to find problems resulting from scripts in smart rules that modify the UI. Not.

3 Likes

That would be the same kind of „problem“ as using the selection in a Smart Rule. Just don’t do it.

Working on files is the purpose of a smart rule. And we all have seen the kind of problems people run into when they use them and don’t remember… If you add UI scripting to the bunch, you’d have questions like “my sidebar suddenly dis- and reappears” all over the place. It’s already enough fun to tell people that their Logitech driver stole a keyboard shortcut from DT.

2 Likes

Seems you don’t use scripts to open windows. I guess otherwise you would understand that it’s desirable to open them the way you want instead of having to manually adjust each opened window - which makes for a quite annoying user experience.

Correct. I usually do not use scripts to automate UI tasks.

Maybe it would be a viable alternative to pass parameters to the open window method @cgrunenberg? That would at least limit the consequences to calls of this method (which hopefully people do not put in a smart rule script).

That might be an option some day.

2 Likes

Another approach might be to add the status of GUI elements (such as the side bar) as properties which can be read but not set. This way, most users would avoid the potential pitfalls described above while the most adventurous ones could tinker a GUI script at their own risk.

GUI scripting is (and always has been) fiddly and troublesome.

1 Like