How to globally toggle app function on/off?

I have an application that runs only as a menubar app. It has a simple command that is essentially “Turn App On”/“Turn App Off”. Is there a way to make Keyboard Maestro set up a global hotkey to initiate the command in this app? I can set up such a keyboard shortcut in the System Preferences, but since the app does not get focus without a Dock app running, I can’t seem to get it to accept the command globally.

1 Like

Selecting status menu items (those little icons in the right hand menu bar) is difficult primarily because there is no easy way of specifying them - they don’t have names so its hard to identify them.

You can use a Click at Found Image, although even that can be difficult as they often animate or change icons based on various states. If the icon does not animate or change state (or has a known state when you want to select from it), then this can be a good solution, followed by Insert Text by Typing “Menu Name%Return%”

To click relative to an image, you use the Mouse Click action, configure it to be relative to a found image, and take a screenshot of the desired area of the screen using Command-Control-Shift-4, and paste it into the image well on the action. The image has to be unique (which includes not being visible in the action if the image is small enough not to be shrunk in the image well) otherwise Keyboard Maestro will not know where to click. The Display option in the action will allow you to see where Keyboard Maestro is matching.

I have looked into it on multiple occasions, and will no doubt look in to it again, but its a difficult problem.

So I can enable it to show up on the Dock and with that I was able to set keyboard shortcuts that work… But I have to get focus on the app first (i.e., cmd-tab). That’s a hassle and I’d rather just issue something like command-option-shift-space to turn it on and then to toggle it back off again. That seems doable with KM, but I’m not sure how to make the Maestro do that per se. I don’t know if I need to make it focus the app first and then issue the key combo or if there’s a more efficient way to do it.

I just ran across this topic which addresses your issue:
osx - How to send a menubar app (with no menubar menu items) a command in AppleScript? - Stack Overflow

I don’t know if you are the OP or not, and I have NOT tested the suggested solution. But maybe it will at least get you started.

This is very easy in KM, just use the

Another option is to use the Select or Show a Menu Item action (KM Wiki), but I’m not sure if it will work in this situation.

1 Like

Thanks, no. I saw that and wanted to see if it could be done with Keyboard Maestro to get some SO points :blush:

But thanks I’m going to play with that and you’re welcome to give that as an answer over there. I feel embarrassed now…

I’m clearly not understanding you.

If there is a status menu, and in there a menu command to turn the app on/off, then you can click on the status menu icon (as described in my previous message) and then select the menu using arrow keys or type ahead.

If that is not what you want to do, how do you manually turn it on and off now?