KM "Type a Keystroke" Action Fails When Macro Activated by Better Touch Tool HyperKey

I’m trying to set up Better Touch Tool's hyperkey, using URL triggers to launch KM macros with BTT. It runs the macros, but any "type a keystroke" actions get the little system error beep and are not executed.

Specifically, I’m having KM type "Ctrl Sh Cmd L" to launch Pixel Snap (screen capture).

If the macro doesn’t contain "type a keystroke" actions, like some I use to call conflict palettes, all is fine. But if it does, they’re skipped; however, other actions in the macro are executed.

Any ideas?

Unfortunately BTT hyperkey only works well with BTT macros.

Can't you set up your hyperkey macros in BTT?

If for some reason you don't want to do that, but want to keep Caps Lock as a "modifier", there is a kind of workaround.

Switch in macos Caps Lock to right control.

Then you have to change the shortcut of all hyperkey macro to right control + letter.

Thanks, Frank.

Here's a key discovery: My problem goes away with a new user account, so there’s something wrong with my account. The challenge now is to fix my account.

After a lot of experimenting last night, I've drafted this detailed description of what’s happening:


Regarding BTT URL triggers: The docs say, "The Hyperkey in BTT is only designed to work well with shortcuts defined IN BetterTouchTool." I’m not sure what that means, because last year, I was told by the developer, Andreas, that you CAN trigger Keyboard Maestro using a url trigger. https://community.folivora.ai/t/hyperkey-unusable/21760/12?u=rbanks88

And I know the URL method really is triggering the KM macro, whether I use the "official" BTT hyperkey setup or the right control key method, because I added a "play a sound" action to the macro.

Once BTT has sent the URL to KM and the KM macro starts, BTT should have nothing more to do with it, right? But check out these four cases:

  1. When BTT sends a URL to KM using ANY modifiers, (including the hyperkey or right-control methods) a KM macro that doesn’t contain a "type a keystroke" action, it works fine. Perfect for KM conflict palettes.

  2. When BTT sends a URL to KM using the modifiers Ctrl Sh Cmd (or any other combination except cases 3 and 4), the macro and any "type a keystroke" actions run.

  3. When it uses the modifiers Ctrl Opt Sh Cmd with the BTT hyperkey setup, the macro runs, but the "type a keystroke" action doesn’t run and gives the system alert sound. (BUT if you just hold those four keys down, it runs.)

  4. When it uses the modifier Right Ctrl with the system keyboard caps lock mapped to right control, the macro runs, but the "type a keystroke" action doesn’t run and gives the system alert sound. (BUT if you just hold Right Ctrl down, it runs.)

So, "type a keystroke" fails when the macro is launched by BTT sending a URL IF the Caps Lock is used, either via the BTT hyperkey method or the Right Ctrl method. Caps Lock seems to be the common thread. (and it’s the same with my cabled and BT Apple keyboards)

It seems this is a Keyboard Maestro problem, unless the URL BTT sends is somehow breaking KM's ability to run a "type a keystroke" action. Could it do that? It's just a URL I copy from KM's "by URL" trigger.


What could be wrong with my account that would cause this? Should I reinstall Keyboard Maestro or Better Touch Tool? Or could it be something else in the system that's broken, causing this issue whenever I use the caps lock key?

Thanks again,
Russell

Until you "Type a Keystroke", at which point BTT may (it will depend on how you've set it up) intercept that typed keystroke... Or it may be that BTT is somehow maintaining the "hyper key down" state at the time KM tries to key stroke, interfering with KM's set modifiers -- does BTT have a specific "release hyper key" action you could use before the URL trigger is sent?

Assuming there is a keystroke conflict -- is there another way to launch PixelSnap in the mode you require? An "Activate application" action, maybe? Do you even need PixelSnap? IIRC it farms out screen shooting to other apps anyway, so you may only need it if you want to include its "measurements" in your image.

With no trial (and seemingly no online documentation) for PixelSnap, this could be a tricky one...

It might help to see the KM macro you're using. You can find out how to post that to the Forum here.

I don't know how or if that helps for anything, but I think I can reproduce the issue.

When I trigger this KM macro with BTT Hyperkey + 5, then the text is displayed, but "5" is not typed.

On the other hand, if I enter the KM shortcut ⌘⌥⌃⇧ + 5, the text is displayed and "5" is typed.

So what does this mean?

Interesting with a short pause at the beginning of the macro it works as it should :slightly_smiling_face:

What's the frontmost app when you are trying that out? For example, in TextEdit manually typing ⇧⌃⌥⌘5 doesn't type anything either.

Yep, looks like BTT is maintaining the modifier keys combo for a while and those are interfering with the KM action, effectively making it

image

Out of interest -- what happens if you replace the "Pause" with a "Release Modifier Keys"?

Manual input triggers everything with every app I've tested.

Yes, both actions work. It is exactly as you say. BTT releases the modifiers too late. So, pause or release modifier. :slightly_smiling_face:

The trick also works when the modifiers are released in BTT. This has the advantage that it only has to be changed there. However, this does not seem to be quite as reliable as with KM.

I’ve tried a .2 pause at the start of the KM macro, the KM Release... action, and the four BTT Key Up actions, an none made a difference. Whenever the caps lock key is involved, the "type a keystroke" action doesn’t run and gives an error sound.

I noticed that when Safari's front, if I trigger the BTT Hyperkey-S shortcut, the R-Click menu pops up intermittently and sometimes selects the last item on that menu, "Inspect Element." In Safari's Develop menu there’s and "Web Inspector" item that appears to be the same, and its shortcut is Opt Cmd I. In this case, I don’t hear the sound I put in the macro to tell when it’s run.

But none of this explains why my BTT hyperkey with my KM macro works fine in another user account. It makes sense, though. If suddenly BTT's hyperkey stopped working with KM "type a keystroke" action, I wouldn’t be the only person on the KM and BTT forums asking about it. And the fact that it works for you good guys is another sign my account may be messed up. (BTW, as I was typing this, the Pixel Snap cross-hairs popped up at the insert cursor's position. Perhaps delayed from my attempts to launch a few minutes ago???)

Here's the macro:

Screenshot for /Screeenshots (auto filename) Macro (v10.2)

Screenshot for -Screeenshots (auto filename).kmmacros (57 KB)

These are two different things -- as you've seen, the first is a right-click on an element in the web page while the second opens the "Web Inspector" pane in Developer Tools.

Right-clicking on a keystroke is unusual. Have you turned on any Accessibility features? Installed some software like Shortcat that will do this? Got into a bit of a loop where KM or BTT are re-interpreting your keystrokes as another trigger? I don't know about BTT, but worth checking KM's Engine log (Editor's Help menu then the Open Logs Folder menu item will get you most of the way there).

How did you get your BTT and KM setups into the other account? If you recreated things rather than doing a whole-cloth migration there might be some settings/triggers/macros you missed.

It does seem to be a clash particular to that account. It may take some digging, but take a systematic approach to your troubleshooting and I'm sure you'll find the problem.

Accessibility features I use:

  • I'm trying to use Voice control more, to ease a little right elbow pain. (what a half-baked tool that is!)
  • I've turned on spring-loading pointer control.
    That's all.

Have nothing like Shortcut. The idea of a BTT-KM loop is interesting. I’ll look into that, and the KM engine log.

For my alternate user account, created KM macros and BTT shortcuts from scratch for my testing.

In the meantime this intriguing idea came to me: Why not just use the option key as a hyperkey?( I can't remember the last time I used option alone as a modifier. Any special characters I occasionally use are set up as KM snippets.) Then, remap the caps lock key to the option key, making it easy to press. (Again, I can't remember the last time I actually turned on caps lock to type a long string in all caps. If needed, I use PopClip for case changes.)

The option key approach seems to eliminate some points of failure. Might it cause some problems I'm not anticipating?

Thanks,
Russell

I finally think I've gotten to the bottom of this, and I feel so stupid! Here's how I discovered the problem:

Of course, remapping the caps lock key to option didn't work, either. So just to see if I could remap other keys, I set control to be the option key, and that didn't work either. In both cases I just got the system error beep.

So now it looked like there's something interfering the Mac's ability to remap the modifier keys. I started looking more closely at that panel and was horrified to notice the "select keyboard" pop-up menu the top. At some point, trying the various approaches, I had remapped the caps key on my BT keyboard to the control key, and my subsequent attempts were addressed to my big, cabled keyboard!

Now, it appears all of my options are once again open to me: the BTT hyperkey, the right control key method, and even my option key idea (which is intriguing because it leaves out BTT all together and works directly with KM)

Any final thoughts, except thinking about what an idiot I must be? :slight_smile:

BTW, s there a log I can look at to tell me what's happened when the system makes its error beep?

Best,
Russell

Merely that everyone who customises their Mac eventually runs into a similar "forgotten tweak" that causes a problem. Welcome to the club!

1 Like