Cancel a Specific Macro Action

Thanks Tobias,

I'm dealing with multiple instances of the same macro. I have macro triggered by a power status change. With normal plugging in and unplugging, it works fine, but when the charging cable is flakey, somehow multiple instances of the same macro get triggered. My idea was to cancel all instances of the macro and then start one instance, but that doesn't seem simple.

Hello August,

Happy new year.

What you’re describing sounds not good .. but there’s a catch for that … Nige (@Nige_S) posted an kmactions group a while ago that can be used to keep only the last instance of a Macro running. Since I don’t have the link to it at hand maybe he has to come up with the link.

But that’s only one solution … I would try another approach and catch up the first instance of the Macro and lock it down with the Semaphore Action and cancel every other instance right away.

Greetings from Germany :de:

Tobias

Another vote for a semaphore lock, unless the cable flakiness is resulting in the first-triggered macro being in a bad state somehow or there's some other reason to kill-all and start again.

If that's the case, something like this group at the beginning of your macro should do the trick. It's a bit long-winded, but you should be able to save it as a Favourite to use anywhere:

Kill Other Instances and Restart.kmactions (7.2 KB)

Image

image

1 Like

Thanks Tobias. Is Nige's macro above what you were thinking about?

Thanks @Nige_S. I don't know how to test that condition. Since a semaphore is relatively easy to implement, I may try that and see if it fixes things.

On the other hand, your "Kill Other Instances and Restart" is even easier for me to implement, at this point. Thanks!

It also uses some concepts that I had not been aware of, such as %ExecutingInstances%, plural, as a list which can then be stepped through. That's pretty slick.

It also uses the shorthand "THIS", which I had previously misunderstood and which you explained above. Seeing it actual use here is very helpful.

Not so much a test as a "you'll know it when you see it". For example -- if the first macro kicks off a process that then has trouble because of the flakiness, killing subsequent instances of that macro via Semaphore won't help. You'll need to either kill all prior instances, leaving just the one that was triggered by the most recent (stable) status change, or go the "Kill All and Restart" route.