Pause Until Mouse is NOT moving and keys aren't being pressed

Any way to prevent a macro from running if your mouse is moving or keys are being pressed on the keyboard? Trying to keep it from interrupting me while I'm actively retouching a photo, etc.

Thanks!

The only (untested) idea I have is to use this shell script in your macro to get the seconds of idle (quiet) time, and then based on that whether or not to continue with the macro:

ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF/1000000000; exit}'

REF: macos - How to detect if user is away in OS X? - Stack Overflow

Another approach is to simply have a macro that toggles a KM Global Variable, like "DND__DoNotDisturb" to "ON" or "OFF".
Then, in your other macros that might interfere, check the value of "DND__DoNotDisturb" and act accordingly.