This one's been bugging me: (no pun intended)
I want to be able to detect when the mouse moves, so I can run an action, kind of like how screensavers exit on mouse movement.
-I didn't actually think it would be too hard but there are some unexpected problems.
I'm using the following script for debugging. The actions I want to run when the mouse moves, run even if I don't move the mouse.
Code:
Labelis:
Loop,
{
MouseGetPos, PosX1, PosY1
Sleep, 500
{
MouseGetPos, PosX2, PosY2
PosXA2 = %PosX2%
PosXA2 += 50 ;prevents small mouse movements being detected
PosXB2 = %PosX2%
PosXB2 -= 50
PosYA2 = %PosY2%
PosYA2 += 50
PosYB2 = %PosY2%
PosYB2 -= 50
if (PosX1 > PosXA)
{
Goto MouseMoved
}
else
if (PosX1 < PosXB2)
{
Goto MouseMoved
}
else
if (PosY1 > PosYA2)
{
Goto MouseMoved
}
else
if (PosY1 < PosYB2)
{
Goto MouseMoved
}
}
Sleep, 50
}
return
MouseMoved:
MsgBox, Did you move the mouse? `n%PosX1% X1 %PosY1% Y1`n`n%PosXA2% large value X2 %PosYA2% large value Y2`n`n%PosXB2% small value X2 %PosYB2% small value Y2`n`nX1 or y1 should be outside these ranges ie. larger than a large value 2 or smaller than a small value 2.
Goto Labelis
#Persistent
Does the code need to be modified or enhanced? Or am I going about this completely the wrong way?
Thanks for your time.