AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple way to react on mouse movement

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
David.P



Joined: 18 Nov 2006
Posts: 237

PostPosted: Fri Nov 13, 2009 9:33 am    Post subject: Simple way to react on mouse movement Reply with quote

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
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 942
Location: Germany - Deutschland

PostPosted: Fri Nov 13, 2009 10:34 am    Post subject: Reply with quote

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
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 942
Location: Germany - Deutschland

PostPosted: Fri Nov 13, 2009 10:37 am    Post subject: Reply with quote

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
View user's profile Send private message
David.P



Joined: 18 Nov 2006
Posts: 237

PostPosted: Fri Nov 13, 2009 10:45 am    Post subject: Reply with quote

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
View user's profile Send private message
nick



Joined: 24 Aug 2005
Posts: 499
Location: Berlin / Germany

PostPosted: Fri Nov 13, 2009 11:04 am    Post subject: Reply with quote

Maybe http://www.autohotkey.com/forum/post-184586.html#184586
_________________
nick

denick @ http://de.autohotkey.com/forum/
Back to top
View user's profile Send private message
aaffe



Joined: 17 May 2007
Posts: 942
Location: Germany - Deutschland

PostPosted: Fri Nov 13, 2009 11:08 am    Post subject: Reply with quote

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
View user's profile Send private message
David.P



Joined: 18 Nov 2006
Posts: 237

PostPosted: Thu Nov 19, 2009 2:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group