Acting on Cancel in a user input dialog blocks Escape and Enter?

I have a macro that has both a Custom HTML prompt and an input dialog onscreen at the same time. When the input dialog is onscreen, it blocks all actions, so I can't close the HTML prompt box until the input dialog box is gone.

If I leave the input dialog box on its default settings, Escape cancels and ends the macro, leaving my HTML prompt box onscreen. I thought, that's fine, I'll just uncheck the Cancel Macro box for the Cancel button, then write a handler for the button response. My handler closes the HTML prompt box (via a Javascript action), then cancels the macro.

This works great, except for this big Gotcha! ... when the Cancel Macro checkbox is disabled, the Escape key no longer works to cancel the macro. I have to click the button, which is highly annoying. And I don't see how I can trap for the Escape key while the input dialog is onscreen, so, am I stuck?

Is there no way to have my macro take action if a user cancels with the Escape key?

-rob.

Just so I understand what you are asking - is it that you want clicking the Cancel Button in the Prompt Dialog not to cancel the Macro (but just close the dialog and move on to do something else) but pressing the physical ESC key on your keyboard to actually cancel the whole Macro? The reason I wanted to clarify before suggesting a solution is that the two bits of your post I have quoted seem be asking opposite things :slightly_smiling_face:

griffman,

Suffix Cancel with /. and it can close the prompt with escape key, and the PromptButton token will return Cancel which you can act on it

image

from action:Prompt for User Input [Keyboard Maestro Wiki]
image

3 Likes

Very clever @macdevign_mac ! I was going to mention the /. suffix but using the Button Token solves it. You could follow the Prompt with an If Then Else Action that Cancels the Macro (or does whatever you want) if the text %PromptButton% is Cancel

Zabobon,
I experiment with lot of KM Actions and thus able to recall using something like this before :} .

1 Like

Perfect, that does exactly what I need. And yes, I worded it very poorly last night: I wanted Escape or Cancel button click to both lead to the same thing: My macro handling the exit from the macro. And that does the trick.

What makes this most embarassing is that I've referenced that page you quoted a lot, because I added the Command-H bit for Help, yet totally overlooked the one for Cancel!

image

image

I think my brain just assumed it should work as is, because the Cancel button was somehow special. Whoops! :slight_smile:

-rob.

2 Likes

Is it possible for a prompt button respond to both Return and Escape?