How to Toggle a Macro On/Off with the Same Hotkey Trigger

So I made a basic auto clicker macro to demonstrate this. I pressed the hotkey (shift command left square bracket) and the macro started. However, when I tried to press the same keys the macro won't stop. How do I enable macro toggle off using the toggle on hotkey?

i was facing the same! did you found any solution?

I suggest you use DwellClick (DwellClick — Clickless mouse software for Mac) because if you use KM to auto-click, KM will take a constant 10% cpu usage for every 2 sec (if you periodically trigger the macro every 2 sec), but DwellClick is designed for auto-click and thus is efficient with cpu (eg if mouse is not moved , there is 0% cpu usage) . Although KM can be used for auto-click, it just not designed for this purpose.

It depends on how your macro works, but here's one example. I'll show it, then I'll explain it below:

image

 
The Magenta-colored action at the start is a "Semaphore", which can only be locked by one process at a time. I changed the timeout options on it so it times out after 1 hundredth of a second, doesn't abort the macro, and doesn't notify you:

 
The yellow-colored "if" action checks to see if the Semaphore Lock failed. If it does, we know the macro is already running under another process, so we set a global flag telling the other process that it's time to stop. And then we exit the macro because our job is done:
image

 
The rest of the macro is just an example. But it starts out by making sure the "stop" flag is reset, which is an important point. Then the macro just loops. When the "stop" variable is set to "1", we know it's time to get out of our loop:
image

 
Here's the macro:

Start:Stop Macro with the Same Hotkey.kmmacros (5.2 KB)

2 Likes