How does one sequentially combine Pause Until one of multiple keys pressed followed by IF,THEN,ELSE actions?

If in a macro, I want to specify sequentially:

Pause until, but with 2 possible options, displayed with a notification

  • press $ to continue macro
  • press Esc to cancel macro

Followed by
If $ continue
if Esc cancel this macro.

Please note that i know the actions Pause Until, Notification and If, Then, Else.

If it is not asking too much, I was wondering how this could be done with the User Input action which I never managed to get my head around. If I could do it with user input it would be great because I image that it would be easier to write the macro if there were not 2 but 5 different options.

thanks in advance for your time and help

This is a bit tricky because you want to use the "$" as a key condition, and actually that is the key 4 AND a modifier key , but the Pause Until can only test for 4 since it must also test for an OR condition of ESC.

So, we have to use a compound test using Execute Until and Pause Until.

Here you go.
One note: While the macro test for these keystrokes, they are still passed on the frontmost App and window.
Also, you must hold down the key for a bit, I'd say at least 0.3 seconds.

So, I would suggest testing this with BBEdit or similar app.

MACRO:   Pause Until Keystorke [Example]

~~~ VER: 1.0    2020-01-09 ~~~
Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

DOWNLOAD Macro File:

Pause Until Keystorke [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


One thing you need to add is a Cancel Macro action in the IF/THEN that finds the ESC key.


Does this work for you?


thank you very much for all the time and energy you put into this.
If I understand correctly, when the choices are many, you would tend to go in the direction of some kind of a palette (conflict or other) rather than a user input menu. That was the core of my question.

Sorry, that was not clear to me from your OP.

IAC, I don't understand what you are trying to achieve.
Displaying a palette will NOT pause or delay the processing of further Actions in a Macro.

If you could provide a more detailed, real-world example of what you want to automate we will be able to make better suggestions.

1 Like

thank you for your reply.
Once again, I was not clear.
Let's stick to the core of the issue (which I should have done). I am trying to figure out how KBM savvy forum members handle the following:

  • request for user input: do you want to send an email to Adam, Mary or Tom ?
  • appears on the screen : press A for Adam, M for Mary, T for Tom (note: there are 3 options here, but there could be many more). In each case, I would send an email with a different recipient.
    Do experts like yourself (appleScript aside) create a macro for each option (possible email) and create a palette (conflict or not) with triggers like A M and T or are there more elegant ways, like some form of pause until ... and wait for the user to type A, M or T ?
    thanks again

I would almost always use a Prompt for User Input action:


When the prompt appears, you can always pick the choice by type select, so press A for Adam, M for Mary, T for Tom.

Then use a Switch or Case action based on the KM Variable "Local__Person" to set the specific message for each person.

Does that do what you want?

1 Like

Thanks very much.

1- you answer my question perfectly. It's exactly what I was looking for and did not know about.

2- I was hoping for some kind of menu to type the names (or 1st letter). My only problem with dropdown lists are a small irritating lag between the time the letter (A,M orT) or name is typed and the list records the entry, but I can live with it.

3- I tried a simple example of my own, and ... it did not work. There must be something basic that I am missing.

thank you

Snapshot and attached macro

Prompt for user input multiple choice DROPDOWN LIST.kmmacros (3.3 KB)

I'm afraid you are missing something basic about the Switch/Case action, though I don't blame you for that since the wiki page explaining it doesn't have any examples of using it with more than one case. The reason this action is a good alternative to using multiple, nested, If/Then actions is because you can include as many different if/then scenarios, or cases, inside a single switch. So in your example, it would look like this (and thank you for including both the full macro and screenshot; it really does make it a lot easier to help):

Prompt for user input multiple choice DROPDOWN LIST (Switch-Case).kmmacros (3.6 KB)

To add more cases to a single switch like this, you just need to click the green plus button next to any case:

For what it's worth, I understand you want to experiment with different methods for selecting one set of actions out of several possibilities, and that's fine, as each method certainly has its advantages and drawbacks, but for this particular scenario, I think I would personally go with a palette and assign each macro a single key trigger like A, T, etc. that is only active when the palette is visible, as that's the fastest way to achieve the two step process of A) run macro B) type letter to select desired option.

1 Like

This is a problem that seems to be unique to the KM popup menu control, as I've never observed it in any other app. Perhaps @peternlewis can explain.

Yes, it is a subtlety that KM uses in several of its comparison methods:

  • Use "is" to compare strings (characters)
  • Use "is =" to compare numbers

This is also the case with the other comparison operators:

Unfortunately, I can't find anywhere in the KM Wiki where this is documented.
@peternlewis, we need to update the wiki.

That is certainly a valid method and may be preferred by those that like palettes.
The disadvantage, IMO, is that now you have a separate Macro to maintain for each of the choices. This leads to duplicate code (Actions) and can allow unintended errors to creep in.

@ronald, to give you, and others, a better view of the choices for using a pick list, I have just uploaded this tutorial macro. I hope it will help all better understand the choices, and to pick the best tool for the job at hand.

MACRO: Methods to Pick from a List [Tutorial]

If you, or anyone, has questions about these methods, please post in that thread.


@JMichaelTX @gglick
You both taught me a lot. thanks very much GG for the macro and JM for the tutorial and thank you both for your pearls of wisdom.
The mistake I made originally was to use the numerical = instead of is all within the same switch action. Because it did not work, I extended to multiple switch actions.

My approach will be to:

  • use the switch method and put an example in my custom action list when the list of actions corresponding to each choice is quite limited and corresponds to a specific recurrent need.
  • when the list of actions becomes more elaborate, I will use the palette

It would be nice if the master @peternlewis would:

  • give more examples in the switch action wiki
  • state in bold that = is reserved for numerical values
  • allow users to insert customized actions with Cmd-Ctrl-A

thanks again very much to both of you !.

1 Like

If I understand what you mean by this, then I would have to say that the more choices you need to select from, the less a palette makes sense.

Image if you have 50 people to select from. Do you really want to create 50, nearly identical Macros, and maintain all 50 as you make changes to your workflow?

OTOH, if each choice results in a mostly different workflow, the using a palette makes sense.

1 Like

You are 100% right. I was looking at the 50 person problem from another perspective: an unduly long macro with a massive tedious to edit Switch action. In the example above, there is only one simple action per person.

It is documented in the Variable condition, which you can get to by holding the option key down and selecting Help: Variable Condition from the insert condition menu (same for lots of other places in Keyboard Maestro).

As always, it could be documented more thoroughly.

I don't see any "Help" when I do that with the Switch/Case compare menu:


I think you want to use this action but possibly just haven't come across it yet.

No, for the Switch, it should be in the Switch action help, but it looks like that has not been updated for the newer conditions.