Keyboard Maestro “Watch For Any Keyboard Entry” Macro

I want a macro to respond to any character entered at the keyboard and disable my alarm clock macro!

Keyboard Maestro “Watch For Any Keyboard Entry” Macro

Watch For Any Keyboard Entry.kmmacros (2.6 KB)

1 Like

Given that you presumably don’t know for sure you are in a place where pressing the delete key will simply delete the typed character it is probably a bad idea to leave the Simulate matching deletes before executing option checked.

I submitted the macro for review and feedback too quickly without properly expressing that I wanted feedback on the regular expression and its effectiveness to achieve my stated goal. I’ve heeded your caution and removed the Simulate matching deletes before executing check! What’s your thoughts about the regex?

Secondly, how would I also detect input at the MacBook Pro trackpad?

Personally, I’d just use the regex (?s:.) which is all you need to match any character pressed.

You can detect the mouse movement, but there is no trigger for that.

You can detect the mouse/trackpad click using the USB Device Key trigger (probably).

2 Likes

I’m trying to capture the single keystoke, and continue a macro while a ‘user input’ prompt is active.
Would there be a way to do that?

macro a:
do this
do that
enable macro b: Watch For Any Keyboard Entry
User input on screen - waiting for one keystroke
’paused until any key typed’ (capture key and continue macro)
do this
finish that

Troy,

I'm still learning, so maybe one of the more experienced users will also reply. Perhaps you can use something like I've shown above as the macro b and the following as macro a where macro b could set Keystroke_Variable based upon key typed (i.e. '%TriggerValue%'

Keyboard Maestro “A” Macro

A.kmmacros (3.2 KB)

Thank you for your response. - no workee though -
I think the issue is that I want a user input dialog box up and active on the screen.
That’s where the ‘pause until any keystroke’ would occur.
That once any single keystroke, alpha numeric, is made, KM simulates a return to dismiss the user input dialog. Has captured the keystroke (which is easily done in the user input dialog - to a variable) and then continues.
I’m not seeing that KM is ‘sensing’ any keystokes while that user input dialog box is up on screen.

Create a macro:

Macro "Detect Keystrokes"
Trigger Typed String trigger, regular expression (?s:.), turn off deleting the characters.
Action:
Set variable “Something Typed” to 1
Disable macro “Detect Keystrokes”.

Other macro:
Do stuff
Set Variable “Something Typed” to 0
Enable Macro "Detect Keystrokes"
Pause Until calculation “Something Typed”

1 Like

But it doesn’t work with an onscreen user input dialog up on the screen. Thats the goal. To capture the keystroke that is entered into an onscreen, ‘Prompt for user input’ , to capture the one keystroke and then continue the macro by typing ‘return’ to dismiss the on screen prompt. I don’t think the regex is ‘at work’ when there is an on screen window waiting for an ‘ok’.

Keyboard Maestro Engine, for technical reasons, cannot detect the keys within its own application.

1 Like

Troy,

Can you share what you’ve tried since the suggestions Peter & I provided. If I’ve read Peter’s response correctly, what I offered incorporating Peter’s corrections (i.e. use his regex and uncheck Simulate matching deletes before executing) should work.

As has been pointed out many times, you get the best assistance from others when you post your macro.

I appreciate the help. I think what people are missing is that there is an on-screen. Prompt for user input. The goal is to type one keystroke in that user input field and have that key captured and have KM type a return to continue the macro.
Truthfully, it's not that important, there are 100 ways around this, but I wouldn't mind it working.

  • Peter said [quote="peternlewis, post:10, topic:4839, full:true"]
    Keyboard Maestro Engine, for technical reasons, cannot detect the keys within its own application.
    [/quote] so getting this to work with the on screen dialog is not possible.

Key_Capture_Continue.kmmacros (8.3 KB)

You could use a Custom HTML Prompt window, which would presumably let you detect a keystroke, set a variable and close the window.

1 Like