Go to Outline and Hide Sidebar

Hello, I’d like to ask for an advice on what are applescript commands to activate Outline and hide Sidebar.

I’m trying to amend this cool script http://bylr.net/3/2015/05/omnifocus-view-project-in-new-window/ – it works fine, but the problem is that Sidebar is activated when new window pops up, each time one needs to click or shortcut to get into Outline to edit tasks. In addition, as sidebar is displayed by default in my settings, in here it has however no value added. So if there was a command to hide that would also be nice.

Can anyone advice please? Thank you.

There is probably a more elegant way, but I invoke System Events to mimic the keyboard shortcut for hiding the Sidebar and Inspector panel. The script below opens two of my most-used perspectives in this manner. Does this do what you need?

tell application "OmniFocus"
	tell default document
		make new document window with properties {perspective name:"Dashboard"}
		tell application "OmniFocus" to activate
		make new document window with properties {perspective name:"Planning"}
		delay 3
		tell application "System Events"
			keystroke "s" using command down & option down
			keystroke "i" using command down & option down
		end tell
		activate "OmniFocus"
	end tell
end tell

There’s a related discussion here Show/Hide sidebar.