Preference Not to Display the KM Status Menu

Hey Laine,

I don't use the Status Menu much, but...

  • I have a macro that opens it for type-selecting some macros I don't use often but want quick access to.

  • I use the Iconaholic Loud icon so I ALWAYS know when Keyboard Maestro is running a macro.
    • This has saved my bacon 2-3 times when a process was taking too long, and I realized it was doing something bad.

I ran for a while without the status menu active, but over the nearly 20 years I've been running Keyboard Maestro I've decided it's not a good idea.

-Chris

1 Like

Yes the main reason I use the status menu is to see when macros are executing, and if they’re taking too long. I don’t actually trigger anything at all from the status menu, especially now that we have macro group menus.

Thanks, Chris!
I don't have trouble remembering my shortcut to Cancel all running Macros, because I use it all the time. I decided to upload the toggle Macro in spite of the fact that there may be display and screen setting that might not let it work. I figured if somebody wants it, they can customize the click actions. I'll probably use the Iconaholic Loud to see if it helps. By the time I finished the toggle macro I was good and mad, as I always am when I work on a macro with more than 5 actions. I know that's not KM's fault, I just barely have enough patience for any kind of macro building. There's always something else it needs, and by then I've forgotten... well, not your problem.
I may use the toggle switch for awhile, now that I have it. Thanks again.

Oops, I forgot. There is one thing that might be your problem. Before I found JMichaelTX's UI script, I tried to get KM to click the General pane of the prefs window from a found image, and that made KM quit unexpectedly as soon as it performed the click. It may be something I should already know about.

Hmm...

Something like that shouldn't crash Keyboard Maestro.

Did the error reporter send the log to Peter?

Also – you can use the Press a Button action for that instead of using a found image.

-Chris

I tried that, must have failed to match the case of "General". Probably gave up after "general" didn't work.

That's one of the issues. It was an unexpected quit, but didn't show a crash. I kept looking to see whether the cursor went to the close button of the wrong window, but it didn't look that way, and I can't figure out how that could have happened, because it was clicking the center of the found image. It's still a possibility, I guess. I can't make it happen now. Transitory issues are almost as bad as intermittent, not quite. Is there a way to confirm from logs what cause the quit?

I made some changes to the macro I posted earlier. Now it will automatically toggle between never showing the menu bar icon, and showing it listed by group.

In the AppleScript itself is a complete list of the 4 options (never, alphabetically, by group, and hierarchically), that way if you prefer one of those other options you can simply swap out the menu item # with the corresponding number.

Let me know if it works for you!

Will do. Thanks!

1 Like

And because I can never leave things well enough alone, I made it easier to set the preferred display option. Version 1.2.

In the first few lines of the script just set the variable menuOpt to the number that corresponds to your preference.

I MAY leave it alone now...or I may continue to tweak it haha.

1 Like

Thanks! I'm not sure that seems easy to me. I'd like to respond right away, but I'll need some time.

No problem! If you do have any questions don't hesitate to reach out (either here or through PM) and I can explain it in more detail.

I like it! I think I'll replace my conditional that handles the Display Status Menu pop-up in General Preferences so I can keep the conditional for whether the macro quits KM Editor.

Sounds like a good idea. You can also change those variables to local variables (in this case local_VarKMrunning) so they don't remain after the macro finishes executing.

OK, well that explains one of the problems I had in my ffmpeg macro. I created some variables without prepending "local_", then expected them to update after I added it. That's a good reason that there should be a way to create a variable in KM in the interface which includes a check box for "local" instead of that clumsy prepending business. I don't suppose there is a check box anywhere in the interface for "local" as it pertains to variables, is there? That's an example of the way that KM often seems to multiply geekiness instead of eliminating it. (leaving rant mode now.)
Thanks again.

No, there isn't. I'm sure there are good reasons that are far beyond my understanding haha.

I really never even used local variables until earlier this year when I got tired of seeing hundreds of variables in my preferences menus. So for several months I went through all of my macros and converted as many of my global variables as possible to local or instance.

Now I have a method to keep variables from accumulating. When I am building a macro or otherwise adding actions that use variables, I have a Typinator expansion that places debug_ before the variable. Once I've verified that the macro works as intended, I have a KM macro that replaces debug_ with local_. I also have a macro that automatically deletes all variables that begin with debug_ whenever the system sleeps in case I forget to delete them manually.

Hi. Hope things are well with you. (Reviving this upon the release of KM 11)

I installed KM 11 today, and this macro appears to kill the KM Engine. I'm not sure why, but if I execute the macro when the KM app is not running, the Status Menu is disabled, but the Engine quits before KM app does. I have to launch the KM app to launch the Engine (that's the only method of launching the Engine that I've tried). I haven't figured it out yet, but it seems to be related to launching it from the Palette. So it could be a bug. It's difficult to troubleshoot when unexpected exit of the Engine is involved. Have you tried 11? Thanks.

I just barely installed it again. I initially installed this morning but because of a bug with the periodic trigger I had to revert to v10 until after I was done working. I’ll be spending the next few days ensuring there are no further issues with v11 and my existing macro library, but I’ll look into this as soon as I can.

1 Like

No rush, this is easily worked around. Thanks!

The crashes stopped, and I increased some delay times to make the macro reliable

Glad you got it to work, but I just took a look at it and here’s a more concise method of doing this.

It’s an "all-in-one” AppleScript that accomplishes the same thing (configured to work with both KM 10 and 11 since the menu item has changed from “Preferences” to “Settings”), and now waits until each window element exists before proceeding. This eliminates the need for arbitrary delays.

Try it out if you’d like and let me know if it does/doesn’t work!

AppleScript (click to expand/collapse)
------------------------------------------------------------
# Author   : Chris Thomerson (@cdthomer)
#
# Version  : 2.0.0 (All in one AppleScript)
# History  : 1.3.0 (Simplified some script to make it faster)
#            1.2.0 (Setting the preferred display option is now done by setting menuOpt to the corresponding number
#            1.1.0 (Script will now toggle between two options)
#            1.0.0 (Initial script)
#
# Created  : Saturday, November 20, 2021
# Modified : Wednesday, October 25, 2023
# macOS    : 11.6.1 (Big Sur) - 13.6 (Ventura)
# Tags     : Keyboard Maestro, Menu Bar
#
# PURPOSE
# Toggle the Keyboard Maestro Status Menu Bar icon
#
# DISCLAIMER
# Permission to use, copy, modify, and/or distribute this
# software for any purpose with or without fee is hereby
# granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
# USE OR PERFORMANCE OF THIS SOFTWARE.
------------------------------------------------------------

----------------------------------------------------------
# List of menu options
# menu item 1 of menu 1 of pop up button 1 of window targetWindow: Never
# menu item 3 of menu 1 of pop up button 1 of window targetWindow: Alphabetically
# menu item 4 of menu 1 of pop up button 1 of window targetWindow: By Group
# menu item 5 of menu 1 of pop up button 1 of window targetWindow: Hierarchically
----------------------------------------------------------

set actDelay to "0.2" # set the time for the delays between actions
set menuOpt to 4 # this number corresponds to the option you want from the list above
set targetWindow to "Preferences: General" # this is the settings window we need to interact with

# set the variable for the menu item for KM versions 10 and 11
tell application "Keyboard Maestro" to set kmVer to get its version
if kmVer contains "10" then
	set menuItem to "Preferences…"
end if
if kmVer contains "11" then
	set menuItem to "Settings…"
end if

tell application "System Events"
	tell application process "Keyboard Maestro"
		
		# bring KM to front
		activate
		
		# open Settings window
		click menu item menuItem of menu 1 of menu bar item "Keyboard Maestro" of menu bar 1
		
		# wait until Settings window opens
		repeat until exists (first window whose name contains "Preferences")
			delay actDelay
		end repeat
		
		# go to General settings
		click button "General" of toolbar 1 of window targetWindow
		
		# wait until in General settings
		repeat until exists window targetWindow
			delay actDelay
		end repeat
		
		# get current status menu setting
		set origOpt to value of pop up button 1 of window targetWindow
		
		# click the pop up button
		click pop up button 1 of window targetWindow
		
		# wait for list to populate
		repeat until exists menu item menuOpt of menu 1 of pop up button 1 of window targetWindow
			delay actDelay
		end repeat
		
		# toggle the Status Menu setting
		if origOpt is "Never" then
			click menu item menuOpt of menu 1 of pop up button 1 of window targetWindow # the option set in the variable above
		else
			click menu item 1 of menu 1 of pop up button 1 of window targetWindow # click on the never option
		end if
		
		# close Settings window
		tell application "Keyboard Maestro" to close window targetWindow
		
	end tell
end tell