Feature Request: Warning about a Hot Key conflict

I just assigned a Hot Key to an application-specific macro. I quickly discovered I'd used that Hot Key for an all-applications macro, which takes precedence.

It would be helpful if Keyboard Maestro gave a warning about such a conflict when the app-specific Hot Key is selected.

I realize there can be cases where having the same Hot Key for all apps and a specific app. For example, I want a specific app to block an all-apps action.

1 Like

That would be kind of cool or some kind of visual in the editor. This is something I do all the time and that I love about Keyboard Maestro compared to QuicKeys is that the conflict pallet is so easy to use and set up and if something gets off that I don't like as in your case it is super easy to go back and find and fix what I didn't want.

On another note, I have a super large spreadsheet that I track all these in and what apps use the all apps shortcuts and rules for different apps key combo. I am happy to share it with you if you think that is of any help. Typically I assign those to Ultra Claw (Command+Option+Control+Shift (⌘⌥⌃⇧)) + key or (Hyper Key) as some fokes call it.

In that case, create a single macro that handles the hot key for all apps, and inside the macro create an IF action that checks which app is frontmost. This will solve that problem. Like this: (you can even use nested IF actions for multiple applications.)

image

Isn't that what the conflict palette does? It warns you when you press the hot key...

https://wiki.keyboardmaestro.com/manual/Palettes?s[]=conflict&s[]=palette

Regarding the warning, I'd like an alert at the time I'm assigning a Hot Key to a macro.

I'm aware of the Conflict Pallete that appears at runtime when two or more macros have been assigned the same Hot Key.

Peter Lewis on this idea, from a prior thread on the same suggestion:

3 Likes

I always love when people know where to find posts that source back to Peter that is super helpful and appreceated.

I am with Peter on that being a useful feature.

I think perhaps what @Ward is getting at, but he can correct me if I am wrong, is that if you assign a keyboard shortcut to something that is "Available in all applications" then put a little warning symble next to it showing that it conflicts with something that will of course run when you are in the application you are planning on using it in.

image

So in otherwords you would never see a warning sign on macros that are groups that are available in all applications but you would see them in groups that are in specific applications.

Of course extra programing and the conflict pallet shows you that as soon as you run it and then you can go back and change it but it would save a little bit of time seeing a little warning the second you make it in a group specific to an application.

Alternatively, if there are very many, you could use Switch/Case instead of nesting if statements.

1 Like

This will be a more viable option once Peter adds all the same options that If/Then actions have. Right now, I often need to use a condition that's only on If/Then actions.

-rob.

Yeah, I struggle with similar limitations, but in this instance switch/case is definitely workable. Is Peter definitely going to be expanding the switch/case conditions then? If so, that's something I'll be eagerly waiting for.

In some thread here somewhere, he commented that it would make sense to do it, though I don't recall anything more specific than that.

-rob.

Ah, okay. I remember there being discussion of it at some point, I thought perhaps there was new information since then.

Being able to seach for Macros via HotKeys, Typed text, MIDI events, etcetera would make it easier to find duplicates.

Isn't this already possible in the search field? Or do you mean something else?

image
image

Are you also aware you can Option-click an item in that palette to open that macro in the Editor so you can easily change the hot key combo? And use the Editor's "Search" box to see what macros use a particular hot key chord?

And what Peter was getting at was that even "Available in all applications" hot keys may not conflict -- what if they are only available in mutually-exclusive window names or are anything but "Always activated"?

So all you'll actually have is a "Hey! This macro shares an hot key trigger with another! It might conflict and it might not -- who knows?" warning. And you can pretty much do that yourself with a Search.

Thanks for the reminder on that. I have been using that for about 15 years for my start and stop playback of Apple music in a way.

  • Play Apple Music by default.
  • Play Pandora instead, if it's open.
  • Play Spotify instead, if Spotify is open (overriding Pandora).

So Spotify has the highest priority for me or, in computer terms, the lowest level of control.

I like that even cleaner.

I am pretty new to using the Switch/Case and really like how clean it is but I didn't realize just how crippled it was compared to the If/Then.

Wowzers, that is awesome I always ran the macro and sorted by last used to get to it. That is so much better, THANK YOU!!!

Yes, this can still use some improvement and I think it is on Peter's bucket list since you are only supposed to be able to see the options that are listed in trigger and depending on the order you have and what you have it will show or it won't show so you have to add - to eliminate. I just made smart macro groups for all 16 of the combinations.

Yeah, it could be a bit messy, and a lot of logic and extra stuff would need to be added to make this possible. So I agree. With that option-click thing, for the most part, I'd say Peter should work on the other list of feature requests, but it would be a nice bell/whistle.

When I type ini a search for command option space I get a Finder search, option A gives me an å.

How do you do this?

I'm not sure what you mean by Finder search, but if you type a hotkey, then the hotkey will be triggered. In order to search by hotkey in Keyboard Maestro, select the group you want to search, then select the search field. From there just type each modifier key one at a time and it will appear in field, after that just type the character (or type out Space for the spacebar) that completes the hotkey you're searching for. In my example above, I searched for ⌘⌥Space because that's my conflict palette hotkey, so I knew I'd get a bunch of results.

Alternatively, you can make a separate smart group to use Search Strings, which includes different triggers.

N.b. It can also be useful to have text replacement/expansion/snippets for the modifier keys ⌘⌥⌃⇧

1 Like

I was typing them all together.

The escape key doesn't work. I tried esc. That worked.

Thanks for that @hemicyon.

Cheers!

1 Like

The reference provided by @NaOH and the observations made in this discussion were hugely helpful in putting together the macro below. I hope it is helpful.

It only searches for macros sharing the first hot key trigger of the Editor's first selected macro. Its data source is the in-memory plist from the getmacros AppleScript command in the of the Keyboard Maestro Engine Suite .

(It cannot show what will actually generate a conflict palette.)

The default scope of the search is all macros. To query just enabled macros, set localQueryEnabledMacros to true.

It searches just a single hot key trigger and does not handle any other types of triggers.

  • Select a macro in the Editor that uses a hot key trigger.

  • Run the macro and it will query what other macros use the same trigger

  • If no macro is selected in the Editor, it shows an alert and stops.

  • If the selected macro has no triggers, a brief notification appears and the macro stops.

  • If no macros are found that use the same hot key, a brief notification that the tested hotkey is not found displays.

  • If 1 or more matches are found, a prompt list of information appears.

  • The prompt title displays the queried hotkey as its title.

  • A sample dropdown line: ":ballot_box_with_check: VBA (:no_entry_sign:) Microsoft Excel."

    Read: The macro, "VBA", is enabled but its group, "Microsoft Excel" is disabled.

  • No :ballot_box_with_check:/:no_entry_sign: emojis appear in front of macros when the enabled option is true.

  • To select the macro(s) in the Editor, select one or more of the names. Click or press return.

Finally, the embedded look up Applescript can be run as a standalone. Copy and paste the Execute an AppleScript action into a macro.

Above it, set a variable named "localHotKeyCombo" to a hot key combination and run. If there are matches, the script will return the source lines for a prompt list.

Below is the Cocoa query that performs the search. I haven't tested it extensively. It should work.

set pred to current application's NSPredicate's predicateWithFormat:("(SUBQUERY( triggers, $triggers, ( ALL %@ IN $triggers.short and $triggers.short.length == %@ ) ).@count >0)") argumentArray:{hkList, keyCount}
set foundMacros to (macros's filteredArrayUsingPredicate:pred)

Getting the syntax right was a pain, so I hope this breakdown matches what the query actually does and vice versa. :crossed_fingers::wink:

  • "macros" is the unnested array of getmacros ("macro") dictionaries, with some minor data shaping. (no actual writeable macro objects are used)

  • %@ and %@ are argument placeholders for hkList and keyCount.

  • hkList an AppleScript list of the individual keys of the triggers of the first selected macro.

  • The subquery treats the nested array of triggers as an unnested array.

  • The "ALL hkList IN" comparison gets an exact unordered match of the keys, ensuring a match regardless of their order in the string to match.

  • The length comparison (keyCount argument) ensures that matches containing additional keys do not appear in the results.

Finally, the @count>0 requires that the number of matches to return, if any, is at least 1.

I hope I got the query right. :crossed_fingers: If not, apologies in advance. I'll try to rework it if I can and/or fix other goofs.
Secret Sharer.kmmacros (19.9 KB)

3 Likes

The problem with this, of course, is that isn't "contextually aware".

Keyboard Maestro to the rescue! Here's a macro that, when run in your desired context (frontmost app, window titles, etc), will allow you to choose a hot key combo to test:

...see if any active macros have that combo -- and, if so, let you go to any of them in the Editor:

Contextual Hotkey Conflict Checker.kmmacros (12.7 KB)

Images

Perhaps a bit rough around the edges in UX terms, but has coped with everything I've tried. What it doesn't do is distinguish between different types of hot keys -- "is pressed", "is down" etc will all be treated as a match. That's what jumping to the macros in the Editor is for -- the lazy way to solve the problem :wink:

2 Likes