Request: USB Device Key Trigger and Mouse Click

@peternlewis I'll make this quick. If you need more info, just ask.

Can you please add some sort of sanity check to the "USB device key" trigger so that if I click my mouse while the trigger control is waiting for the USB device key to be pressed, it does NOT assign the mouse down button as the device key trigger?

Accidentally assigning a macro trigger to "mouse left button down" can be a complete PITA, and takes some creativity to solve the issue. Thanks.


I would prefer a universal, permanent key sequence that disables the engine. My problem is different than yours - I can get seriously stuck when my macros move my mouse and I lose complete control of my mouse that way. My macros are often self-restarting and not even "Cancel all macros" can stop them. Therefore a key sequence that can stop the engine would be a better solution for me, and should also work for you.

There is a key sequence that is guaranteed to stop the KM Editor, (OPT-CMD-Escape, arrow, Enter) but the Engine cannot be stopped this way because it doesn't show up in that list of apps. If it could show up in that list, that would also be acceptable.

Here you go:


tell application "Keyboard Maestro Engine" to reload

Just assign it to your favorite "oh :face_with_symbols_over_mouth:!" key. ;p

1 Like

Just came here to say "been there".. I do chuckle when it happens, but I prefer to think about it like "With great power comes great responsibility".

And KM is great power.

1 Like

I think you overlooked something. My macros auto restart. Therefore restarting the engine won’t make any difference.

OK, then this:

tell application id "com.stairways.keyboardmaestro.engine"
	if running then
	end if
end tell

Just remember that opening the KM Editor will automatically start the engine if it's stopped. So perhaps your macro should first launch the editor, then stop the engine.

1 Like

Unfortunately, no. The trigger looks at low level events with no real semantic meaning.

So create a macro that quits the Keyboard Maestro Engine.

You can cancel all running macros by holding all the modifiers down (Command, Control, Shift, Option) and clicking in the Keyboard Maestro status menu.

You can cancel specific macros by selecting from the Cancel submenu in the Status Menu, or by selecting Start Debugging in the Status Menu, and clicking the appropriate cancel buttons.

You can also see and cancel macros by choosing the Status Menu ➤ Start Debugging menu.

There are also actions for Cancelling All, This, or Other Macros (actions:Redirect Control Flow [Keyboard Maestro Wiki]), which you can use and trigger in any way you like.

You can quit the Keyboard Maestro Engine from the status menu or the Keyboard Maestro editor File menu or via AppleScript or the Quit Application action, and you can launch the editor while holding all the modifiers down to quit all running engines and not launch the engine.

1 Like

I agree, that's why I already "liked" Dan's post which tells me how to do that. As for the other ideas about cancelling all running macros, those ideas don't really apply to me at all because I was talking about macros which auto-restart and move my mouse non-stop (due to programming errors, which do happen occasionally) and I hate to have to cold-reboot my Mac just because of a bug in my macros. Cancelling all macros does nothing for me when I have a bug in a macro that never stops moving the mouse and the macro auto-restarts.

Whenever this bug occurs, it's almost like a game, where I press my shortcut button to cancel all macros, then I have 1.00 seconds to move the mouse across the screen to the KM icon on the System, menu, then move the mouse down to "Quit KM Engine", then click on that item. I still have very fast reflexes at my age, but 1.00 seconds is not enough time to reach that menu, so I have to cold-reboot.

No, never!

Seriously. though, if I had macros like yours, I would build in a fail-safe. Something like checking for a global variable to know they should quit running. and if they start again, they should quit right away.

I realize that this may be a big undertaking with a lot of macros, but you could make it easier on yourself by making one macro that checks for the variable and does a Cancel Macro action if it finds it. Call this macro at the start of each macro, and also during loops inside the macros.

Another option is to make a kill-switch macro that disables all of these macros. You can have a version that re-enables them too. And while this might seem like a lot of work, it doesn't need to be. Let me know if you need an example. I actually wrote a couple of macros to do this for you, but then I realized that this doesn't really help if one macro calls another, because (I think) even disabled macros run when called by other macros,

1 Like