How can I make a KM prompt respond to keyboard input on Wake from Sleep

I have a macro that triggers on wake and (under certain conditions) displays a prompt with two buttons, OK and Cancel.

When I trigger the macro from the status menu or the keyboard, the prompt responds to keyboard input—I can press Return for the OK button or Escape for the Cancel button. But when the macro is triggered by the machine waking from sleep, the buttons have no effect. Sometimes, although not always, this is the case even if I click on the prompt window with the cursor before pressing the button!

I've tried adding a Bring Window to Front action, but I can't figure out which application owns the prompt window—selecting Keyboard Maestro Engine doesn't have any effect.

Any suggestions here?

FYI I'm using Big Sur 11.5.2.

For this question you should mention which version of macOS you are running. That may be important.

You should also indicate if you are trying to select the buttons using the keyboard or the mouse. You kind of implied the mouse when you said "click" but it wasn't 100% clear to me because you also said "press the button" which implies the keyboard.

Your question is very similar (90% similar) to one of mine that I posted a few weeks ago, which hasn't been answered yet.

Thanks—updated my question to include that information.

One difference between your situation and mine is that in my case the macro runs when I expect it to—the only delay is to the prompt window receiving keyboard input.

Ok. I wish I could help, but I can't help myself with my own problem yet.

Hey Gabriel,

Have you tried putting a short pause before the user prompt?

-Chris

1 Like

Chris, thanks for the suggestion—it was helpful.

It seems like the issue is to do with the act of unlocking the computer. If the prompt is triggered after the computer wakes but before the screen is unlocked (which is the usual case with a Wake trigger), the keyboard-focus issue occurs. But when I tried putting a pause sufficiently long that I could unlock the computer before the prompt was displayed, the prompt window got keyboard focus.

So the solution in my case was to replace the Wake trigger with an Unlock trigger. (I'm already testing to ensure the prompt is only displayed once per day.)

1 Like