Preference Not to Display the KM Status Menu

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