Macro Group Enable/Disable based on USB Device been present or not

Hello all. New to Keyboard Maestro and this group.

I have groups of Macros that I would like to Enable or Disable based on a specific USB device being present or not. I have searched the menus, and can only find the ACTIVATION option, but not the ENABLE/DISABLE option.

I have tried using the activation option, but as far as I can tell .. nothing happens :slight_smile:

Can someone here enlighten a newbie so that I can start looking in the right direction?

Kind regards Nils

Create a macro in the Global Macro Group (or some other group that is always active).

Add the USB Device trigger for the desired device being attached or detached.

Also add the Engine Launch trigger

Use the If Then Else action and the USB Device condition, check whether the device is attached or not, and then use the Set Macro Group Enable action to enable or disable the desired macro group dependent on the existence of the USB Device.

You can (and probably should) use the Activate/Deactivate Macro Group action instead of the Enable/Disable action. Enable/Disable is designed to be relatively permanent, and appears in the Keyboard Maestro editor whereas Activate/Deactivate is designed to be situation dependent.

A deactivated macro group will be functionally equivalent to a disabled macro group, and an activated macro group (assuming the macro group is enabled) will mean the triggers on the macros are available to be triggered.

Thanks a lot for your reply.

Can you please be a bit more specific regarding the use of the ENGINE LAUNCH trigger, and what role that plays in this equation ? :slight_smile: kind regards Nils

The Engine Launch trigger is the one you see in the image below. The purpose of this trigger is to run a macro when the KM Engine starts. The KM Engine normally starts when you log in, but can also be started by yourself manually.

2 Likes

As @Airy eludes, the Engine Launch trigger will trigger the macro when the Keyboard Maestro engine launches, which will then allow the macro to set the state dependent on the existence of the USB Device.

This ensures that despite any connection or disconnection of the USB Device that happens while the Keyboard Maestro Engine is not running, the state of the macro group will match the existence of the USB Device as soon as the Keyboard Maestro Engine launches (after which it can watch for the USB Device being attached or detached).

1 Like

Thaks a lot Airy and Peter. So ... this means that the ENGINE LAUNCH TRIGGER will execute at engine start, and that the ACTION field for the ENGINE LAUNCH TRIGGER will reference another macro? Do I understand is correctly ?

Kind regards Nils.

Hello Nils (@nmalexandersen)

No … the Engine Launch Trigger will execute after you log into your account or if you disabled the KM Engine for whatever reason and reenable it.

This trigger also fires before any other trigger which ensures that your USB Device will be either detected or not detected properly….

Greetings from Germany :de:

Tobias

Thanks a lot Tobias...

Just so we are not talking past each other here ...

My question is basically what should be put in the WILL EXECUTE THE FOLLOWING ACTIONS .. part of the ENGINE LAUNCH TRIGGER macro...

Something like this ? ... where the NMA USB Device Trigger macro will sniff for the USB unit ...

Hello Nils (@nmalexandersen):wave:

No … this will not work as intended if the macro you’re calling has the USB Device Trigger.

I give you the advice to get used to Peters Instructions he already gave you and build your Macro based on his description and combine it with the things that you want to happen.

If you’re still struggling after trying out - there is maybe someone else who can help you with the issue you might have then.

Greetings from Germany :de:

Tobias