| View previous topic :: View next topic |
| Author |
Message |
David.P
Joined: 18 Nov 2006 Posts: 237
|
Posted: Fri Nov 13, 2009 9:33 am Post subject: Simple way to react on mouse movement |
|
|
Hi forum,
is there a simple way to do the following:
| Code: | MouseWasMoved::
DoSomething
Return |
I could remotely imagine something with SetTimer, A_TickCount and MouseGetPos...
Or is there a better, easier way?
Thanks lots already,
David.P |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 942 Location: Germany - Deutschland
|
Posted: Fri Nov 13, 2009 10:34 am Post subject: |
|
|
From the help file:
| Code: | #Persistent
SetTimer, WatchCursor, 100
return
WatchCursor:
MouseGetPos, , , id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %control%
return |
|
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 942 Location: Germany - Deutschland
|
Posted: Fri Nov 13, 2009 10:37 am Post subject: |
|
|
So try this:
| Code: | #Persistent
SetTimer, WatchCursor, 100
return
WatchCursor:
lastx:=x
lasty:=y
MouseGetPos,x,y
if !lastx
Return
If (x != lastx or y != lasty)
MsgBox Mouse was moved!
return
|
|
|
| Back to top |
|
 |
David.P
Joined: 18 Nov 2006 Posts: 237
|
Posted: Fri Nov 13, 2009 10:45 am Post subject: |
|
|
Thanks!
What I've done now is the following:
| Code: | SetTimer, MouseMute, 222
MouseMute:
MouseXOld := MouseX
MouseYOld := MouseY
MouseGetPos, MouseX, MouseY
MouseDiff:= (Abs(MouseXOld - MouseX) + (Abs(MouseYOld - MouseY)))
If (MouseDiff > 66)
DoSomething
Return
|
Agreed?
Cheers David.P |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 499 Location: Berlin / Germany
|
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 942 Location: Germany - Deutschland
|
Posted: Fri Nov 13, 2009 11:08 am Post subject: |
|
|
I agree like this:
| Code: | #Persistent
SetTimer, MouseMute, 222
Return
MouseMute:
MouseXOld := MouseX
MouseYOld := MouseY
MouseGetPos, MouseX, MouseY
MouseDiff:= (Abs(MouseXOld - MouseX) + (Abs(MouseYOld - MouseY)))
If (MouseDiff > 166)
msgbox %MouseX% %MouseY%`n%MouseXOld% %MouseYOld%`n%MouseDiff%
Return
|
I´m wondering why the msgbox is directly shown again when I click it away. |
|
| Back to top |
|
 |
David.P
Joined: 18 Nov 2006 Posts: 237
|
Posted: Thu Nov 19, 2009 2:34 pm Post subject: |
|
|
| aaffe wrote: | | I´m wondering why the msgbox is directly shown again when I click it away. |
This is because
| Code: | | CoordMode, Mouse, Screen |
is missing from the script. It then uses the msgbox's cooordinates and thinks the mouse has moved.
Thanks
David.P |
|
| Back to top |
|
 |
|