Triggering a macro multiple times with a modifier held down

I have a macro that I trigger using a stream deck, and I trigger it with the KM action, and I want to use it with the command key pressed.

Screenshot 2024-07-05 at 11.45.23

It works.
But when I keep pressing the command key, and run the macro again, KM does not trigger this macro. Only when I release it, and press it again, it works.

The same behaviour happens with the ctrl key.

The same behaviour happens when I insert an ifthenelse with the condition Command Modifier Down.

When I use a key on my keyboard together with the command modifier instead of the stream deck it works as expected.

How can I solve this?
Or is this something our beloved Guru should do?

My Stream Deck Mobile (which is a Stream Deck emulator for iPad) does not work that way. It triggered every time, even without releasing the modifier. So my conditions aren't the same as yours, but I'm not getting your problem.

Did you turn on your debugger and click on "Pause New Macros" (or check the log) to confirm if the macro is triggering or not?

Thank you Airy.

No, I have not done the debugger routine . I have to admit that I still don't know how it works and never dived into it. I always found other ways to debug.

But, there is another macro triggered that is triggered by the same StreamDeck key but then without the command modifier. Let;s call that Macro1. Macro 2 is the macro that is triggered with the Command key down.
So, when I press command and press my tigger key; it launches Macro 2.
I keep holding down the modifier,
I press the trigger key; it launches Macro 1. (But I expected to launch Macro2)

So, I know that the trigger key works, but I also know that the modifier is not seen as being down as the wrong macro is launched.

I understand. You have proven that Macro1 launches. But to be honest, you haven't proven that Macro2 doesn't launch, which is what I was trying to show with my advice about the debugger. Since I can't see Macro2's code, and since I can't see your log, I can't prove to myself it's not launching. Did you check the Engine log file?

There's definitely a chance that my line of inquiry will not result in your answer, but it will help to confirm that your assumptions (that Macro2 is not triggering) are correct.

"macro1" does not trigger when command is down. So I do know.

Ok, sorry, I've done all I can do without being able to see the macros.

Thank you for thinking along!

ok. I made a test macro and now it does not happen. There must be some actions in the macro with the command key that influences this behaviour and I have to figure that out first.

Ok, I found the issue. It's a key press.
I made a test macro that has this behaviour. (almost. )

Modifier test.kmmacros (4.5 KB)

Import the attached macro.

On your StreamDeck, make a profile that is active when the Finder is at front.
Insert the Keyboard Maestro action on your streamdeck and give it a unique RCnumber if it doesn't have it already.
Edit the trigger of the imported macro so that the stream deck action triggers the macro.
Close the StreamDeck editor windows.

Switch to Finder. (The macro will press the "=" key so make sure it doesn't mess around with something that you don't want. )

• Launch the macro without the Command modifier.
• There will be a notification that say "Command Modifier is Up"
• Press the command modifier and launch the macro.
• There will be a notification that say "Command Modifier is Down"
• Release the modifier key
• Press the command modifier and launch the macro.
• There will be a notification that say "Command Modifier is Up" THIS IS WRONG! It is down!
Whatever state the command key is in now, it will all the time tell you it is up. Only when you switch to another program and come back to the finder it resets.

It looks like the Key Press Action, if it has no Command Key in it as action, resets the status of the command key in KeyBoard Maestro. You can see this by observing the "currently false" or "currently true" status of the condition in the If then Else.

@peternlewis
Can you have a look at this?

This is behaving as expected (by me).

To simulate typing to =, Keyboard Maestro has to simulate releasing the Command key in order to type the = (not ⌘=). And then after that it simulates pressing the Command key.

But then at the end of the macro, because it is Keyboard Maestro that pressed the Command key, the key is released when the macro finishes (otherwise you could have a case where the simulated Command key is stuck down indefinitely).

I have had cases lately when the shift key was stuck indefinitely, and I still have no idea what's causing this. Could this be the same cause? Sometimes to solve the problem I have to reset the KM Engine.

I do have a Stream Deck (mobile) attached, but I haven't touched it in weeks. So I infer that the Stream Deck is not relevant to causing this problem.

Not with Keyboard Maestro (for the reasons stated above).

I saw that sort of thing years ago when I was using a tool to provide Capslock ➤ Hyper Key mapping, so I stopped using the tool.

I understand that the key command for the modifier is 'released' after the "Press Key" action. (I know by experience what happens if a modifier stays in the pressed state forever...). But in reality, I mean physically, it is still held down.
I would love to know a workaround for my issue

Whether it is physically down or not does not correspond to the state of the system at that point for the reasons I've described.

This is exacerbated by the fact that physical and simulated keystrokes and modifiers are not really the same (for example, simulating pressing the Command modifier, and then physically pressing the V key will not generate a Command-V).

Unfortunately you will need to change your expectations to work around this. Perhaps use some other facility to determine the state of the physical keyboard (if there is a way to do that, which I'm not sure there is).

ok. Thank you for the answer. Let's get creative then!