Is there a better way to choose outcomes?

Hi, I'm fairly new to KM and would like some help.

I have a macro that starts with a prompt with a drop down menu giving me 5 options. Depending on what I choose the macro needs to do different things, then finish with the same series of keystrokes regardless which choice was made.

Currently I have 5 nestled if/else actions. It works, but this seems a really clunky way to do it. It's confusing to edit and to see what is happening. Is there a better way to choose what it should do from the outcome of the variable in the prompt?

Thanks for your help

Use the Switch/Case Action.

4 Likes

An alternative would be five macros, each with the same trigger, then Keyboard Maestro will ask you which one to execute. Then each macro can finish with an Execute a Macro or Execute a Subroutine action that executes a sixth macro to perform the final steps.

See: Conflict Palette.

1 Like

In addition to the above comments -- you don't have to nest "If..." actions. You can chain them, ignoring the "Otherwise" section, if that suits the logic of your macro. Example, including a "Switch/Case" for comparison:

Chained Ifs and Case.kmmacros (12.8 KB)

Image

Thanks all. I've gone with the switch/Case option, but all very useful comments.