AutoHotkey Community

It is currently May 26th, 2012, 3:47 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Need help with OnMessage
PostPosted: April 23rd, 2008, 6:55 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
I tried adapting the following example from the documentation.

I'm new to OnMessage, but I've read all the help files and can't see the problem.
Could someone please point out what I'm missing?
Thanks much.
Code:
;Example from documentation
OnMessage(0x5555, "MsgMonitor")
OnMessage(0x5556, "MsgMonitor")

MsgMonitor(wParam, lParam, msg)
{
    ; Since returning quickly is often important, it is better to use a ToolTip than
    ; something like MsgBox that would prevent the function from finishing:
    ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam%
}

Code:
;My attempt to adapt the above examlpe to monitor mouse movement (WM_MOUSEMOVE = 0x200)
OnMessage(0x200, "MsgMonitor")
MsgMonitor(wParam, lParam, msg)
{
    ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam%
}


Edit: I also tried this, which didn't work either
Code:
OnMessage(0x200, "WM_MOUSEMOVE")
return

WM_MOUSEMOVE(wParam, lParam, msg)
{
    ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam%
}


EDIT_2: I'm pretty sure I'm doing something very fundamentally wrong because I have just tried the following without success.
Code:
OnMessage(0x21, "WM_MOUSEMOVE")
OnMessage(0xA0, "WM_MOUSEMOVE")
OnMessage(0x200, "WM_MOUSEMOVE")
OnMessage(0x20A, "WM_MOUSEMOVE")
OnMessage(0x2A1, "WM_MOUSEMOVE")
OnMessage(0x2A2, "WM_MOUSEMOVE")
OnMessage(0x2A3, "WM_MOUSEMOVE")
return

WM_MOUSEMOVE(wParam, lParam, msg)
{
    ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2008, 9:17 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
wm_mousemove will only register mouse movements on the scripts own window. Is that what you wanted???

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2008, 9:27 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
thanks for the reply.
No that's not what I want.
I would like to know whenever the mouse makes any physical move in any window.
This is so that the script can release the Lbutton so as not to drag things it shoudn't when user moves mouse.

Any ideas?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2008, 9:29 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
Do you want to disable mouse dragging completely????

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2008, 9:35 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
No, infact, the script will be dragging from time to time
In between dragging Lbutton should release but sometimes it doesn't and then when user moves the mouse it causes things to get dragged which is very troublesome.

Edit: the script I'm using is basically this one:
http://www.autohotkey.com/forum/viewtop ... 138#192138


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 24th, 2008, 4:56 pm 
Offline

Joined: August 27th, 2007, 8:00 pm
Posts: 179
Others may feel differently but I feel that this is an acceptable bump based on the low difficulty level and the line count.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 25th, 2008, 11:57 am 
As posted above:
Superfraggle wrote:
wm_mousemove will only register mouse movements on the scripts own window.

So OnMessage will not work as you want.

You might want to try something like this:
Code:
#SingleInstance, force
#Persistent
#NoEnv

; your code here
SetTimer, checkMouse,100 ; set to what ever period you desire
; more of your code here
return

checkMouse:
  MouseGetPos, newX, newY
  if (newX != oldX) or (newY != oldY) {
    ToolTip, Mouse moved - newX: %newX% newY: %newY%
    oldX := newX, oldY := newY
  }
  return


Report this post
Top
  
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: 0x150||ISO, Bing [Bot] and 20 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