Wiki Update: Switch or Case Action

The following Wiki Article has been updated, and is submitted for your review, comment, and/or revision:

###Switch or Case Action

###Primary Changes

  • ADD screenshot of initial, default configuration
  • Rewrite primary description
  • ADD sections
  • ADD links to parameters
1 Like

Looks good.

I wish the Switch or Case Action could support more conditions such as “The Application” .

1 Like

How do you want to use it?

For example, the shortcut to Refresh differs from each other among some apps.

Chrome → ⇧⌘R (Forece Reload)
Safari → ⌘R
Reeder → ⇧R
Airmail → ⌥⌘R

I unified them to ⌘R. Although I could do the job with nested “If Then Else”, but “Switch/Case” would be better logically.

Another case, if I have different macros related to different apps, and I want to sign all macros to the same trigger (e.g. F10), “Switch/Case” is a great choice.

1 Like

@JMichaelTX perhaps a grouping of (condition i / not condition i) can be more compact, meaningful and readable…
Just a thought.

You can use the "Switch" Action for this, just use the "Text" condition with a Token of FrontMost App Name:


Alain, I’m not sure what you mean. Could you provide an example?

@JMichaelTX solution:

was where I was headed with my question.

Alternatively, if you want to have per-application triggers, the normal way to do that is to create a macro group for each application. For example, there is no real advantage to having a single Command-R Refresh macro with a switch based on application as opposed to a macro group for each application and a macro for each. The former will rapidly become difficult to maintain as the number of such macros increase.

The exception would be a case where a macro did a lot of things, and only a small amount of it was application-specific.

There is perhaps one advantage: Keep things simple.

With only one macro, there is only one macro to maintain, only one place to look for issues with the hot key trigger.

Having said that, I would probably take @peternlewis’ approach, but have a common, consistent name for all of the macros. Maybe something like:
@Refresh <app name>

Then you could use a macro search of “@Refresh” to find all of these macros.

I will answer in wiki category for clarity…

@JMichaelTX -

You post many very useful techniques here.


This forum software already has a symbol to award "likes" ...

But ... is that sufficient motivation to anyone to continue posting useful ideas?

For outstanding posts -- like that approach to using a Token -- could this forum add a symbol to award a steak dinner?? ...
And actually provide a dialog box to enter my credit card or a Bitcoin #.

More substantial ideas could really "earn" more substantial awards.

1 Like

I’m sure @JMichaelTX would not turn down a proffered steak dinner (he is from Texas, so I figure that’s safe!), but generally the Like button is sufficiently useful, and occasionally a replied “Thanks” post is appropriate.

But definitely, if anyone is visiting Texas (or Perth!), I’m sure a steak dinner would be appreciated :wink:


Well said, my friend.

BTW, if anyone who uses Keyboard Maestro is ever in the Houston, TX area, please PM me. I might actually buy you a steak. :wink:

1 Like

I have made further changes to clarify Switch Conditions.
###Switch Action Conditions

As always, submitted for your review, comment, and/or revision.



1 Like