How can I priorize one macro?

Hello, ive few macros running in my laptop, they are running fine however I need make a priority list for them, example:
Macro X is trigged
Macro Y is trigged
Macro Z is trigged

I want to keep Macro X trigged and Pause Macro Y and Z until Macro X isn't trigged, how can I do that?
Thank you so much
Kind Regards

Easy.
Have MacroX set a variable, say "DND__MacroX_Status" to "Running" at the top of Macro X.
At the end of Macro X set it to "NOT Running".

Then in the other Macros, add this at the top:
While action

While DND__MacroX_Status is "Running"
Pause 1 sec
End While

You can, of course, adjust the Pause to suit your needs, but I would not make it less than 1 sec unless you expect Macro X to run in less than 1 sec.

1 Like

Is this what semaphores do automatically?

3 Likes

I think I didn't understand how to do this
ive 3 different macros running when a application is running and they're trigged when recognise a pixel in a specific position, the problem is that sometimes they trigger at same time and it generates a problem in this application, I need to priorize if one is trigged wait until the macro is not trigged

I suppose yes hahah

Possible to have 1 macro receive the trigger then it decide which macros to run (and when) using the Execute a Macro action? Execute a Macro has an option to allow asynchronous launching.

Trigger => Controlling Macro started which does:

  • Macro X launched, controller wait for macro to end
  • Macro Y launched, asynchronously
  • Macro Z launched, asynchronously
2 Likes

Yes, you're right. I forgot about semaphores.
Of course, that would require that Macro X must always be triggered first.

Using the KM Global variable approach, it could be easily adapted to pause the other Macros even if they were triggered first.

1 Like

That is a much better approach than what I was thinking.
Simpler and more robust.

FWIW, here's my example of Macros X, Y, Z.

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Please let us know if it meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Macro X -- Must Complete Before Other Macros Can Run [Example]

-~~~ VER: 1.0    2021-06-14 ~~~
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:

Macro X -- Must Complete Before Other Macros Can Run [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Macro Y -- Must Wait for Macro X to Complete [Example]

-~~~ VER: 1.0    2021-06-14 ~~~
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:

Macro Y -- Must Wait for Macro X to Complete [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Macro Z -- Must Wait for Macro X to Complete [Example]

-~~~ VER: 1.0    2021-06-14 ~~~
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:

Macro Z -- Must Wait for Macro X to Complete [Example].kmmacros
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


1 Like

First of all thanks so much for your help, I really appreciate this!
Sorry for being so stupid but just to be sure, should I add my macros inside this ones that you provide? Is it ok if I disable the notifications cause it will trigger every 5 seconds and will be so annoying to see notifications all the time.
I noticed that in macro Y and Z there's a place"put your actions here" but not in macro X that's why im asking if I should add in macro X also.

You should add your ACTIONs in each Macro.
For Macro X:

Of course. The "Notifications" were just my test actions.

No such think as a stupid question. Do your homework, do your research, do your testing, and feel free to ask any related question.

Maybe this will help:

Getting Started with Keyboard Maestro

For more help, see Getting Started with Keyboard Maestro and the Forum .