Code: Select all
wait>1
GetCursorPos>xx1,yy1
OnEvent>CUSTOM,MyTriggerSub,DoIT,DoSomething
SRT>MyTriggerSub
GetCursorPos>xx2,yy2
if>{(%xx1% <> %xx2%) OR (%yy1% <> %yy2%)}
Let>DoIT=TRUE
Endif
END>MyTriggerSub
SRT>DoSomething
exit>0
END>DoSomething
label>start
wait>0.5
goto>start
I know this is pretty simple, but I thought it might be useful to somebody, even just as a starting point. I have a lot of macros which enter large amounts of text very quickly. Sometimes I want to stop them halfway through, and it will result in havoc when pressing shift+esc. Sometimes the macro will continue for a few seconds and will type in garbled info which i have to then clean up afterwards, or it will run wild, attempting to open hundreds of new office documents, etc. I expect we've all experienced this in one way or another.
So I wrote this simple little script which detects a mouse move and stops the script with no keyboard action required. Of course, it won't work as is with a script which moves the mouse, but I'm finding it really useful for breaking those fast, "keyboard only" macros.
Here it is :
REMARK> ####### SET UP THE SAMPLE LOOP ######
Run Program>notepad.exe
waitwindowopen>Untitle*
wait>0.5
let>a=1
REMARK> ####### SET UP THE SAMPLE LOOP ######
REMARK> ####### GET YOUR ORIGINAL CURSOR POSITION ######
GetCursorPos>X,Y
REMARK> ####### GET YOUR ORIGINAL CURSOR POSITION ######
REMARK> ####### SAMPLE LOOP WHICH WILL BE BROKEN BY MOUSEMOVE ######
label>startloop
sen>%a%
press enter
let>a=a+1
gosub>endloop
goto>startloop
REMARK> ####### SAMPLE LOOP WHICH WILL BE BROKEN BY MOUSEMOVE ######
REMARK> ####### IF MOUSE HAS MOVED, END ######
SRT>endloop
GetCursorPos>NEWX,NEWY
if>NEWXX,end
if>NEWYY,end
End>endloop
REMARK> ####### IF MOUSE HAS MOVED, END ######
label>end