How to switch keys? (macros chain-reacting, not playing nice)

ui_control
triggers

#1

I'm trying to make my underscore _ key easier to access:

The macros:
hotkey \ becomes _
hotkey option+\ becomes \

The problem:
Pressing \ works great, a _ pops out every time.
Pressing option+\ fails, returning a _ instead of what I want (I want \) :frowning: I think it's because it does create a \, but then the other macro kicks in and changes it again to a _

How do we stop this recursive fighting amongst macros?


#2

Simulating a keystroke that is the hot key of an active macro is an undefined behaviour. It may be swallowed and trigger the macro, or it may be typed normally.

You could use a sequence like:

Disable Macro
Type Keystroke
Pause
Enable macro \

The length of the pause is the problem. And indeed, Keyboard Maestro does essentially this, but since there is no way to know how long that pause should be, it is unreliable.

If the pause is short, then the \ may trigger the macro.

If the pause is long, then you may not be able to type a \ when you want to.


#3

This works great, _ \ !

But whenever I type opt+\ to get the \, this box in the middle of the screen flashes up saying “Keyboard Maestro ENABLED slash to underscore”—Is there any way to disable that?

My setup now is two groups, one called slash to underscore with the hotkey \ turning into _

The other group is two macros, the first on opt+\ pressed disables the slash to underscore group, and types out a \. The second macro is on opt+\ released enables the slash to underscore group again.

This works, but with the annoying flash sign popping up in the middle of the screen. What can I do about that?


#4

Oh I found out you can uncheck “Display toggle” on activating macros macro. Woohoo! Thanks for the support!