Toggle Sidebar as absolute on or off - not either or


#1

Solved:

I am enjoying using KeyboardMaestro to set up TaskPaper windows that I am working on. Some TP projects depend on the sidebar being visible and some, do not need the sidebar to be visible. The challenge I am having, is that the sidebar is currently adjusted by the option-alt-s key combination as either hidden or showing. This means, to show or close it is basically an on/off switch. TaskPaper documents remember the status of the sidebar when they were last opened. When going to different TP documents and using the macro, I am getting very inconsistent results when applying show or hide sidebar.

This may be because sidebar visibility settings are set globally instead of for each document. I framed my question the way I did as it seems very difficult to determine conclusively that a certain TaskPaper document is going to open with or without a sidebar showing. By this I mean that if I set the macro to always open the document, send it to a part of the screen, and simulate the key press of option-alt-s, sometimes I get a sidebar that was already showing to hide, and sometimes I get a hidden sidebar to show. It depends on the previous state of that document or the previous state of the last document I had opened in TaskPaper. I cannot simply open a document, tell it the condition of the sidebar for that document, and have a consistent result.

Why this is important is because I am using two TaskPaper windows side by side in my workflow. I have replaced nvAlt with a Taskpaper document that needs no sidebar and then I open my task list beside it that uses a sidebar. Normally, this works out fine - unless it doesn’t. Sometimes I have to run it a couple of times as it has remembered a sidebar before it opens the first no sidebar window. I also have my writing outline open with a different macro on a different screen, again, side by side and this time with no sidebar for either window.

If the macro opens the documents and positions the windows before the sidebar changes, then the windows have to be repositioned which defeats the point of the macro just a bit.

The only way around this if it were even possible, would be to query if the hide stylesheet menu was selected previously or not, then do an if/then selection. I don’t know that it is possible to query a menu selection like that in TaskPaper?

Is there some way to do this that I might have missed? Or, could this be something to look at for a future version of TaskPaper?

Added: One way of resolving this would be to have separate commands for hide and for show sidebar. Then you could set different key combinations such as, option-alt-s = show, shift-option-alt-s = hide.


#2

Not sure if it’s accessible, but notice that the View > Show Sidebar menu item has a state value indicated by the checkmark to the left. When the checkmark is present (state == on) then that means the sidebar is showing. With the “System Events” scripting dictionary you might be able to read that state from the menu item, and then you would know if you needed to activate the item to show the sidebar or not.


#3

Thanks. This is a little beyond my reach. My Applescript skills are weak. I will post this on the KeyboardMaestro forums and see if I can get a response. When I do, I will reply back - if I find a solution.

Looking, here.

This is in the right direction but it is for TaskPaper and not for the individual window or document. No matter what with this I get the three beeps - open of closed sidebar.

tell application "TaskPaper"
	activate
	
	tell application "System Events"
		tell process "TaskPaper"
			set frontmost to true
			set activeMenuItem to enabled of menu item "Show sidebar" of menu "View" of menu bar 1
			if activeMenuItem is true then
				tell me to beep 3
				display dialog activeMenuItem
			else
				tell me to beep 2
				display dialog activeMenuItem
				
			end if
		end tell
	end tell
end tell

end tell

I added the specific document and I still just get the three beeps.
I added the display dialog activeMenuItem which is always True, showing or hiding the sidebar for all TP open documents.

A Solution!

I heard back on the KeyboardMaestro forums that KM can do this. Hurray for KeyboardMaestro, it saved the day yet again.

This checks for an open sidebar and, if found, closes the sidebar.
46 PM

This checks for an closed sidebar and, if found, opens the sidebar.
05 PM