How to Use Same Keyboard Shortcut (Hotkey) to Cycle (Toggle) Between Two Different Macros

This is what I want to happen. Use a shortcut ⌘⌥T and have it cycle between triggering two different macros every time I press it

Example
The first time I press ⌘⌥T it will trigger macro 1
The second time I press ⌘⌥T it will trigger macro 2
The third time I press ⌘⌥T it will trigger macro 1
And so on...

2 Likes

You could try something like this:

  • Do NOT assign the hotkey "⌘⌥T" to either Macro #1 or Macro #2
  • In Macro #1, Set Variable Macro_Last_Run to "1"
  • In Macro #2, Set Variable Macro_Last_Run to "2"
  • In a third macro, I'll call the "Master Macro":
    • Set the trigger to hotkey "⌘⌥T", or whatever you'd like
    • Use a IF THEN action to:
      • IF Variable Macro_Last_Run = "1"
      • THEN Execute Macro "Macro #2"
      • ELSE Execute Macro "Macro #1"

Questions?

2 Likes

It works perfectly. Thank you!

1 Like

Hi! Can you attach the picture with "In a third macro, I’ll call the “Master Macro”? It helps me a lot, i'm new in keyboard maestro. I can't understand this part

Use a IF THEN action to:
IF Variable Macro_Last_Run = “1”
THEN Execute Macro “Macro #2
ELSE Execute Macro “Macro #1

i'm stack

Thank you!

I made a video to explain it :slight_smile:
https://v.usetapes.com/NlutumEuB7

1 Like

You are the best my friend! thank you so much for helping me, I really appreciate it!
Best wishes, Alex

I am glad it helped you.

Can be done in one macro. :slight_smile:

Cheers,
Arnold

38%20PM

4 Likes

The macro that Arnold suggested for using the same hotkey to trigger first one action and then a second works brilliantly.

I would like to use the same hotkey to trigger a series of three macros, one after the other by pressing the same hotkey.

Does anyone know if this is possible?

Thanks in advance!

Certainly. You just need to use a Switch/Case action instead of If Then Else:

EXAMPLE - Same Shortcut, Three Macros.kmmacros (7.0 KB)
image

Just make sure to replace the placeholder actions with the appropriate Execute a Macro ones.

1 Like

Thanks. That looks great.

And the reason for the last part repeating Macro 1 is in case the variable doesn’t exist yet so, gets reset?

No problem. And yes, the last part is basically only for the first time the macro is run, so that you don't need to create the MacroNumber variable manually in order for it to work.

And the nice thing is it can be adapted to any number of macros. I managed to change it to two:

EXAMPLE - Same Shortcut, Two Macros.kmmacros (5.6 KB)

2 Likes

Is there a way to have Macro 1 activated while i press down the key and Macro 2 activated, as soon as i release the key?