I Need a macro to select items from an application running in my system toolbar

I would have attached a macro to this post if I only knew where to start. I have a sound application running in my toolbar that re-routes my audio to 1 of 3 outputs. I am trying to figure a way to switch between the audio outputs which are available from the context menu of the application.

The audio outputs on the menu are System, Main and Reference.

To get started I figured I'd simply record the action of selecting the app on the toolbar and then click to select the output but for some reason that doesn't seem to work at all. I tried searching the forums library and couldn't find anything to start from either.

Basically I just need a macro that will select this application (or ideally any application) from my system toolbar and allow me to select the available options off of the dropdown menu when a menu is available.

Anyone have any samples as to how I might accomplish this?

Click the Share button at the top of the window with the macro selected, then click OK.

Perhaps because it's a toolbar item, which have different behaviors than regular apps? Not sure, though.

This isn't necessarily an easy thing to do, because (again), the menu bar applications aren't "real" applications. That means their menus aren't visible to most apps, including Keyboard Maestro.

There are many ways to do this in Keyboard Maestro; this is a method I've used in the past. Make a macro that:

  • Click at Found Image, where the found image is the icon in the menu bar. It's OK to include a bit of the surrounding icons if they never change.
  • Once the menu is onscreen, you can then use typed letters (maybe) or move and click mouse some distance down from the current location (should always work) to select an item.

Here's a basic macro that will not work on your system, but shows the above structure, including options for either typing letters or moving and clicking the mouse.

Download Macro(s): Menu Bar Extra.kmmacros (18 KB)

Macro screenshot

Macro notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System information
  • macOS 14.5
  • Keyboard Maestro v11.0.3

The key to making Found Image work is to grab an image like this:

With the menu bar visible, press Shift-Command-Control-4, then drag out a region that has your menu bar icon in it, ideally either at the left edge or centered. Then in the Found Image action, click the image well area and press Paste.

You then need to figure out where in the image to click to make it click your icon—set X and Y locations relative to a corner or center of the image, and then click Go to see where the mouse goes:

As long as you can find a unique image, Found Image should work quite well for this.

Please let us know if you have additional questions.

-rob.

Thanks griffman!
The found image suggestion works perfectly when I created the macro, selected both actions but when I pressed the assigned key combo nothing happened.

What am I missing? It obviously works when I used the try button. :worried:

Sonnox System Audio.kmmacros (15.8 KB)

Two suggestions:

  1. Add a very brief Delay action, as in my demo macro, to give the menu time to populate.
  2. Control-1 is used in macOS to switch Spaces; maybe try a more obscure shortcut first?

-rob.

Ok, I did as you suggested but it persisted not to work until I used a key combo that didn't use a number. Is that right? Technically a number should be a valid character to include in a keystroke, no?

It should be fine (I have tons of shortcuts with numbers in them), which implies that something else is trying to use that same shortcut. There's a freebie app called ShortcutDetective that can help find such things, those sometimes it crashes.

-rob.

And now it doesn't work again :face_exhaling:
I'm on version 10.2
I figured maybe an issue with the KM Engine so I restarted and ensured the engine was set in the system to start on login. Worked at first then stopped.

Any other suggestions?

Open the logs folder (Help > Open Logs Folder), and open Engine.log in a text editor. Scroll to the end, do you see any error messages from when you tried to invoke the macro?

-rob.

2024-06-01 11:40:24 Execute macro “Sonnox System Audio” from trigger The Hot Key ⌘1 is pressed
2024-06-01 11:40:24 Action 14843295 failed: Move or Click Mouse no unique image found
2024-06-01 11:40:24 Move or Click Mouse no unique image found. Macro “Sonnox System Audio” cancelled (while executing Move and Click at (0,0) from the Center of the Found Image).

Btw, I did change the shortcut key back to using the Cmd + 1 just of curiousity

So it's having trouble finding the image. If the icons around that one don't change, try making your image larger, to include them (gives KM more to look for). You can also experiment with the fuzziness slider, and check the "Display" box to see what KM sees—use the "Move" item in the Gear menu for that action to test it without running the macro.

-rob.

2 Likes

Perfect, that did it. there was enough space on both sides of the icon for me to make it larger and adjust the fuzziness. Works like a charm now.

Thanks a million! :smiley: