Same Shortcut for Trigger And Type Keystroke Action Without Loop

If an user press a shortcut for a program, I’d like for KM to pass the shortcut to the program but also process another action.
In order to do that, I created an action to type the same shortcut, but it seems like it creates a loopback.
Is there way to do this without assigning two different shortcut for hotkey trigger and type keystroke action as well as without creating a loop?

Yep, as you have found, a macro can't issue a Keystroke that is it's trigger, without a loopback, or unpredicatable results.

So, the usual solution is for the KM Macro to use the "Select Menu in Application" Action that is the equivalent of using the App's shortcut key:

Thanks for the clever suggestion. What if the shortcut action is not in the application menu? Thanks!

Get Outlook for iOS

You may want to double-check to see if the menu item appears if a modifier key is held down.

If not, then the only workaround I know is to use a different KM Hot Key trigger that is NOT the app shortcut. Of course, you can also use other trigger types, like “Trigger by Name”, “Status Menu”, etc.

It’s control+p and definitely not in the menu. It’s window specific shortcut as well. I guess there’s no option Other than different hotkey trigger or non-hotkey trigger in this case?

The only other possibility I know of is to use AppleScript, if the app supports scripting, and the command for the function you want is provided.

Use a USB Device Key trigger - it will detect the keystroke but will not interfere with its normal processing.

So, to make sure I understand this, using a USB Device Key trigger will allow the trigger to simultaneously be used by the system/app, correct?

Thus, the app is responding to the trigger (shortcut key) at the same time the macro is running. If you want the macro to do something with the app, after it has finished responding to the shortcut key, then you would have to put an appropriate Pause Until Action at the top of your macro.

Correct. The macro is triggered and the system continues on as if Keyboard Maestro was not there, so the key is processed normally.

The macro then needs to take in to account that the key has been pressed and allow time for it to do it’s thing (or otherwise work properly regardless of the continued processing of the keystroke).

Simple solution I found was to disable the macro, fire the keystroke, and enable the macro. That did the trick, and it didn’t cause any loop! :slight_smile:

Yes, the problem is there is no way to know how long to leave the macro disabled for because the simulated keystroke might take some time to get through the system.