While Loop Where the Condition Is the Mouse Is Moving

Is it possible for a loop condition to be "the mouse is moving"?

Here is an untested idea:

  • Set KM Variable Local__Mouse to token %CurrentMouse%
  • Use the KM Until action with these Actions in the Action loop block:
    (these Actions will repeat UNTIL the mouse stops moving)
    • Pause 0.1 sec
    • IF Local__Mouse is %CurrentMouse%
      • THEN Break Loop
      • ELSE
        • Set KM Variable Local__Mouse to token %CurrentMouse%
        • Add whatever other Actions you want to execute while Mouse is moving
  • Add whatever Actions you want AFTER the mouse has stopped moving.

Again, this is UNTESTED, so you will likely need to make adjustments.

Thanks for your help.

Your idea led me down the right path and I was able to find a solution. I wanted to resize a window by pressing a modifier key while moving the mouse. It seems to work now:

resize window.kmmacros (11 KB)

1 Like