Pause until, but with 2 possible options, displayed with a notification
press $ to continue macro
press Esc to cancel macro
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.
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))
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.
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 ?
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.
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):
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.
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.
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
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.