Access state in a menu TaskPaper

I have a challenge which I am not sure how to achieve in TaskPaper. TP has a menu that allows a condition to turn a sidebar on or off. Unfortunately this feature is unaware of the condition of the TaskPaper document and if there is already a hidden or a visible sidebar before it is triggered. Therefore, when I want to set up a KM macro to open a document and set it's sidebar to be shown or to be hidden, it is a bit of a crap shoot to see if I can open the document the way I would like to open it, with an open of a closed sidebar. Since the macro also sets the window bounds, changing the sidebar after the macro does not work very well since it messes up the window location and running the macro a second time is another crap shoot. The show/hide sidebar is simply an on off switch and does not set that document to an absolute condition.

Here is what the TaskPaper developer suggested as a solution:

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.

My AppleScript skills are very poor. I don't know how to determine if such a thing is possible or how to implement it if it is. I would use a conditional in my KM macro of course if there was a way to determine the menus state. But how to get that information using System Events as he suggested is beyond my reach.

Can anyone be so kind as to help me resolve this?


Progressing but not solved:

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"
	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
				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.

Menu is not marked condition


1 Like

Wow, is this cool. I can do this in KeyboardMaestro?!!. I've said it before and I'll say it again, KM Rocks!

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

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

1 Like