Wish: App-specific Hot Key supersedes a Global Hot Key

I have two simple global hot keys I use literally hundreds of times a day:

  • F13 = Hide current app (aka Command-H)
  • F14 = Hide other apps (aka Option-Command-H)

Although the standard keyboard shortcuts are easy enough, I find it quicker to press a single, conveniently located key.

Today, I attempted to override these two keys for one specific app:

  1. Created a new Macro Group that’s limited to the specific app.
  2. Created macros for the F13 & F14 hot keys that simply perform a System Beep.

I expected my app-specific macros would supersede the global macros. Instead, pressing each hot key pops up a tiny window, asking me to choose between the app-specific macro and the global macro.

I realize I can use If-Then-Else to embed my app-specific actions in the global macros. But I’d really like to keep app-specific coding isolated in the app-specific macro group.

– Ward

You are seeing the conflict palette that shows automatically when a trigger applies to multiple macros - there is no “override” of global macro triggers by app-specific macro triggers. What you can do is, for the global macro triggers that you wish to override, place them in a new global macro group that is active in all applications except the ones for which you want to have “overriding” app-specific triggers. If you’ve got a lot of apps where you want to “override”, though, and you want to override different triggers in all of them, this will get pretty unwieldy. But, if it will just be a few, e.g. F13 and F14 (which can do different things in different apps), just segregating a few out shouldn’t be that burdensome.

People coming from other macro programs occasionally express this desire.

Keyboard Maestro has no hierarchy of triggers because Keyboard Maestro has a rich set of ways that macros can be activated and deactivated, so there is no clear way to distinguish when a macro has sufficiently more priority than another to make it override rather than ask.

For example, say you have:

Macro Group “Everywhere” which is Always active.
Macro Group “Finder” which is active only in the Finder.

You would have the macros in the Finder group override the macros in the Everywhere group. OK, but now what happens if you have a macro that explicitly activates and deactivates the macro group “Everywhere”. Now, say the macro group Everywhere is currently deactivated, and you do the sequence: Activate Macro Group Everywhere, F13 - and that would trigger the macro in the Finder group without asking which would be unexpected in this case.

It could be taken further, say it only applies explicitly to the Global Macro Group - a special case group I really don’t like, but exists to have somewhere for new macros to be created if no group is selected, and which are always active. Ok, so say I implement this, and the Finder group overrides that macro in the Global Macro Group. But then you decide, hmm, I don’t want my global F13 macro to operate when I’m playing Kerbal Space Program, so you make a new macro group that excludes the game and put your macro in there, and now unexpectedly it loses its “specialness” and you get the conflict that was being hidden before.

Better (at least in my opinion) is to accept that all active triggers are equal, and to design your macros with that in mind, either using appropriate macro groups to control the activations, or If Then Else on specific macros, depending on what is appropriate.

1 Like

Thank you, @peternlewis, for your scholarly tutorial (which I need to study more closely).

I’ll confess my perspective is based on decades of creating hundreds of QuicKeys shortcuts.

@rolian’s naming the “conflict palette” has adjusted my take on this: the Conflict Palette controller gets involved when a specific hot key is tied to several enabled macros. For example,

  • All Apps macro “default-action”
  • ABC-app-specific “abc-action”
  • XYZ-app-specific “xyz-action”

The Conflict controller logic could be …

  • If ABC is frontmost Then do abc-action
  • ElseIf XYZ is frontmost Then do xyz-action
  • Else do default-action

To preserve current Keyboard Maestro behavior, there could be an “Automatic Conflict Resolution” preference that users like me could turn on to enable the logic shown above.

The current Conflict Palette would still be required if …

  1. Two or more current-app macros have the same hot key trigger.
  2. There is no current-app macro enabled, but there are two or more all-apps macros enabled.

For the time being, I’m explicitly coding automatic conflict resolution into my F13 (Hide current app) and F14 (Hide other apps) macros as follows:

  1. Remove the hot-key triggers from my app-specific macros.
  2. The F13 & F14 macros are a single If-Then-Else step:
  • If Application “XYZ” is at the front, execute XYZ’s macro.
  • Otherwise, execute the default Hide action.

That has the advantage of isolating the XYZ-specific Hide actions in the XYZ macro group.

P.S. I’m sure some readers are wondering why I need application-specific Hide & Hide Others behavior.

The application in question is Splashtop, a screen sharing app that lets me view and manipulate the screen of a remote Mac. When the remote screen is frontmost, most keyboard shortcuts are passed to the frontmost window on the remote screen. Command-H and Option-Command-H are exceptions – they apply to the Splashtop app and not the window on the remote screen. The TeamViewer screen sharing app has the same problem.

Since I can’t stop my fingers from pressing my F13 and F14 keys, my Splashtop-specific Hide macros simply beep.

Since you've stated you would really like to keep app-specific coding isolated in the app-specific macro group this may not be your ideal solution, but nonetheless, I think it may be your best practical one: instead of using If-Then-Else, you could use the Switch/Case action to create exactly the conflict controller behavior you describe for macros in a global macro group, albeit on a per-macro basis (though if you do this a lot, you could also use @DanThomas's KMFAM to create a reusable template pre-filled with the same apps to make it easier):

Example Conflict Controller Macro.kmmacros (3.4 KB)
54 PM

Coming from Quickeys can be quite jarring - Keyboard Maestro and Quickeys have very different philosophies on how things should work, and it is likely going to take you some time to get used to the differences. In general, most people end up asking why they didn’t switch sooner, so hopefully your experience will be the same.

As I explained previously, there is no hierarchy of macros in Keyboard Maestro, and no real way to do one because there are too many ways that macros can be activated or deactivated, which means that there is no one way to “order” the priority of macros.

Also, as a general rule, I wont add “mode” preferences in Keyboard Maestro - in fact, I avoid preferences altogether as much as practical.

An important thing to learn about getting the most out of Keyboard Maestro is that the Conflict Palette is not some sort of workaround to get around a troublesome problem of having two macros inadvertently using the same trigger. Instead the view should be that the Conflict Palette is a powerful and useful tool in allowing a single hot key to perform a variety of related tasks. With this in mind, you can dramatically reduce the number of hot keys you use (and thus need to remember) and that enhances the utility of all of them.

This is a good solution.