Avoid Multiple Macro Triggering With Semaphores?

I have two macros, and I use a semaphore in one of them, and it works fine, but it doesn't stop the other macro. I tried to add a semaphore to the other macro, but it doesn't work

I'm trying to figure out what's going on with semaphores. I don't quite understand the same semaphore name, using the same name in each of my macros doesn't seem to work, I don't know what I'm missing?

Test Semaphore Macros.kmmacros (3.9 KB)

I think that perhaps at the moment there is a problem with the style of your questions:

They impose too much effort on potential helpers (trying to make sense of the context) which slows things down, and reduces what you get from the process.

You (and the forum) might get more benefit if you were to:

  • step back from the detail of a failing solution, look at the broader picture of what you are actually trying to achieve, and provide thread titles general enough to be useful to others later,
  • provide examples of typical input, and the output you hope for
  • make sure that you have really understood the XY problem, and think about ways of avoiding it.

At the moment it's often not easy for others to help you much, which is a pity.

2 Likes

Why would it? The second macro doesn't have a "Semaphore lock" action so it isn't going to check. You need the "Lock" action, referencing the same semaphore name, in every macro that you want to make wait.

(Do you actually need a semaphore lock? Could you not simply call the second macro from the first at the correct time?)

1 Like

Yes, I'm trying to figure out what's going on with semaphores.
I don't quite understand the same semaphore name, using the same name in each of my macros doesn't seem to work, I don't know what I'm missing?

Test Semaphore Macros.kmmacros (3.9 KB)

What is the actual problem that you are trying to solve ?

Why do you think that semaphores might be part of a solution ?

I just want to know if it is possible to avoid the multiple macro triggering problem by semaphores. Earlier @Nige_S gave me another way to do it without using semaphores. But I still want to do it in another way. It is that I need to copy the image by right click and then trigger it by clipboard change, so I have two kinds of trigger actions. But in the end it only avoids one of the macro internal triggering problem.

As in this example, is it possible to avoid multiple triggers?

1 Like

The minimum timeout is 1 1/100th of a second. Your Mac is running "copy that" (and changing your clipboard) faster than that so instead of timing out and not executing it runs and runs and runs and runs...

Put a 1 second pause in both macros and you'll see they work as expected.

1 Like

Very good! Thank you for your help. You've done me another big favor.:slight_smile: