Adding a Modifier to a Keystroke

I want to hold down the cmd key on my Mac keyboard, while I press the P button. This should open the Print dialog in the Preview app. But it doesn't! Instead, it just makes a bleep noise.

What am I doing wrong?


Hey Jon12345,

Try removing action 3 where you press the Command key.
Where you now have keypress P, change to CMD P by pressing both keys.



You could also replace the last two steps (which can't work as the key presses are one after another as @Neo has spotted) with an Action to directly access Print in Preview through Preview's Menu:


As a rule it's generally more reliable to access menu items in Apps directly (if they exist) rather than simulating keystrokes.

1 Like

@Neo is right on the money.

A semi-related suggestion: instead of a two second pause, use the pause until action and use the print menu item exists, and then use the select a menu item action instead of the keystroke. This will make it run quicker and you don’t have to worry about shortcut mapping if you ever override that CMD-P shortcut for any reason.

If that didn’t make sense just let us know and we can show some examples. :grin:


EDIT: Back at a computer... as @Zabobon said (beating me by one lousy minute haha!) the select menu item is generally a better/more reliable way to access menu items. Try this on for size:

18)Print daily planner.kmmacros (3.1 KB)

Macro screenshot (click to expand/collapse)

1 Like

Hey, I like that idea. Didn't know that existed and it looks more reliable.

I like your Pause until idea. However, in your example code, won't it pause until the File>Print appears, yet you have to get to the next line of code to make it appear?

No, it doesn't need to "appear" on screen... it just needs to exist in the file menu, which KM can detect even in the menu is not open.

1 Like

Ha ha! I saw you were typing as I pressed the Reply button. :rofl:

1 Like

Right! I'm a coder, so sequentially it didn't seem right. But I get your drift now.

Some brilliant answers in this thread, so thanks for that.

1 Like

I seem to be getting stuck in a loop. When I click cancel on the popup Print dialog, it reopens again. Why might that be happening?

Print Daily Planner.kmmacros (3.6 KB)

I don't see anything in the macro that would be causing that. Try turning on debugging, pause new macros, then run it again to see what's happening.

Odd. It happened once this time. Then nothing the third time. Then some Mac exception error for Preview. I will keep an eye on it.

That's odd, never even heard of that happening, but it sounds unrelated to KM. Keep us posted if you have more issues with the macro.

I have the issue where I have 1 macro bind to Hyper + V and then another macro that triggers that keystroke, but the former macro doesn't get activated.

I use the following macro to split each line of my last clipboard entry into multiple pastes until I deplete all my lines, by pressing Hyper + V I achieve that: Separate each Line on System Clipboard onto it's own Clipboard

This is the macro:

Now say I want to paste fifteen lines and I don't like to press the Hyper + V fifteen times, I made a new macro when pressing Cmd + Ctrl + Shift + V it should execute Hyper + V each 0.75 seconds until I press Escape. This does not work, as it doesn't trigger my former macro (in my case trying to execute Hyper + V), but it actually does work, say I bind it to a any Key, or even Cmd + V, it will execute those keys and keystrokes successfully, but it just won't execute my macro if it is bind to one of those keystrokes.

So all of this is fixed if instead of typing the Keystroke, I execute the macro:

I wanted to ask why is this the case? Why I can't type in a keystroke that triggers a macro?

If you look at the KM wiki action:Type a Keystroke [Keyboard Maestro Wiki] you'll see it says this pretty near to the beginning;

Do Not Use for the Keystroke of an Active Hot Key Trigger

You should not use this action to simulate a keystroke that is the same as an active Hot Key Trigger. Typing a keystroke that is the hot key trigger for an active macro has unpredictable behaviour, it may type the keystroke or trigger the macro, and which will vary depending on unpredictable factors including the load on the Mac, the version of OS X or Keyboard Maestro and other factors.
Instead use the Trigger Macros by Hot Key action if triggering the macro is desired, or alternatively, find another way to cause the desired action (eg use the Select or Show a Menu Item action to select a menu instead of simulating a menu command key).

If you really need to simulate the keystroke, then you will need to deactivate or disable any macros with the matching hot key trigger, type the keystroke, pause for it to be completed, and then re-activate/enable the macro.

You've used Execute a Macro which is probably how I would do it.

1 Like

Thanks! However I will just probably use execute macro as I did in the last image, since this is more flexible and I don't need to change two bindings if I change the binding to the original macro. Let me know if there are any issues with this approach.

Edit: Ah I read now that you confirmed this too. So thanks!

1 Like