How Do You Check Running Macros?

I have some macros that pause until an image is found that gets triggered by a hotkey. How can I check to see if it is running?

Also, how can I add multiple images to Found_Image?


Set a variable to 1 when it starts, and 0 when it is finished (though you need to ensure that the macro never aborts for any reason, which is tricky).

Add multiple conditions, each with one image, and adjust the condition selector as desired for β€œor” or β€œand” behaviour.

It is generally best to ask different questions in different posts as otherwise it makes it hard for anyone else coming later to find the question/answer.

Is there an easier way by now? Creating variables (and having to clean them up manually) to "implement" one's own makeshift mutexes strikes me as odd, clunky and error prone.

There are sempaphores in Keyboard Maestro now. Like this action illustrates:

So if you are asking about mutexes, I think that's the answer to your question. They are a feature of KM now, and they don't require using variables anymore.

But if your question is about something else, like how to check if a macro is running, please explain.


Thank you for telling me! Indeed, a semaphore β€” together with a short timeout that terminates the macro in case the semaphore is already being held β€” is a great way to avoid running multiple copies of a macro concurrently.

1 Like

Yes, the KM semaphore action allows timeouts. One thing I use them for is when my macros control hardware. For example, if I write a macro that moves the mouse, I lock a semaphore called "Mouse" to prevent it from conflicting with any other concurrent macro that may also want to lock the mouse. In this case, I don't use the timeout feature because I usually want both macros to run, just not at the same time.

1 Like