You can stop a specific instance of an executing macro with the Cancel a Specific Macro action.
Example 1:
Macro Doit, Trigger Shift-A
Actions:
- Set variable DND_Macro Doit to text “%ExecutingInstance%”
- Do stuff
Macro Cancel Doit, Trigger Shift-V
- Cancel a Specific Macro “%Variable%DND_Macro Doit%”
Example 2:
Macro Doit, Trigger Shift-A
- If variable DND_Macro Doit is not empty
- Cancel a Specific Macro “%Variable%DND_Macro Doit%”
- Set variable DND_Macro Doit to text “”
- else
- Do stuff
- Set variable DND_Macro Doit to text “”
To handle the case where the macro fails or aborts for other reasons and so DND_Macro Doit is not cleared, you could go a little further and validate whether %Variable%DND_Macro Doit%, when it is not empty, is or is not in ExecutingInstances token. But probably this is not necessary, since the only result would be that pressing Shift-A in this case would “cancel” the already not running macro, and then pressing it again would start it.