AutoHotkey Community

It is currently May 27th, 2012, 1:20 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: November 13th, 2009, 10:33 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 11:34 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 11:37 am 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 11:45 am 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 12:04 pm 
Offline

Joined: August 24th, 2005, 5:29 pm
Posts: 549
Location: Berlin / Germany
Maybe http://www.autohotkey.com/forum/post-184586.html#184586

_________________
nick :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 13th, 2009, 12:08 pm 
Offline

Joined: May 17th, 2007, 12:07 pm
Posts: 1004
Location: Germany - Deutschland
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 3:34 pm 
Offline

Joined: November 18th, 2006, 7:56 pm
Posts: 305
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], iDrug, Ohnitiel and 23 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group