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.