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 

Need help with OnMessage

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



Joined: 27 Aug 2007
Posts: 179

PostPosted: Wed Apr 23, 2008 5:55 pm    Post subject: Need help with OnMessage Reply with quote

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%
}
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 970
Location: London, UK

PostPosted: Wed Apr 23, 2008 8:17 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Wed Apr 23, 2008 8:27 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 970
Location: London, UK

PostPosted: Wed Apr 23, 2008 8:29 pm    Post subject: Reply with quote

Do you want to disable mouse dragging completely????
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Wed Apr 23, 2008 8:35 pm    Post subject: Reply with quote

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/viewtopic.php?p=192138#192138
Back to top
View user's profile Send private message
Leon



Joined: 27 Aug 2007
Posts: 179

PostPosted: Thu Apr 24, 2008 3:56 pm    Post subject: Reply with quote

Others may feel differently but I feel that this is an acceptable bump based on the low difficulty level and the line count.
Back to top
View user's profile Send private message
rickly
Guest





PostPosted: Fri Apr 25, 2008 10:57 am    Post subject: Re: Need help with OnMessage Reply with quote

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
Back to top
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