Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Mouse Messages

Mouse Messages

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    carp
    wrote on last edited by
    #1

    What is the best way to differentiate the mouse movements I call in my program (using SendInput or SetCursorPos) from other mouse movement messages? I'm using a system wide Mouse hook in a .dll that receives all mouse messages / movements and I want to distinguish mouse movements as a result of the physical mouse as different from the mouse movements and clicks I send to Windows through my program. My program moves the mouse around using SendInput and SetCursorPos and clicks using mouse_event. I want my program to relinquish control of the mouse when the user moves the physical mouse. How can I tell the difference in a system wide hook? I've tried embedding dwextrainfo into the movement and click calls that my program makes to tell them apart from the other messages, but my program calls seem to generate other, additional and simultaneous messages that do not contain the dwextrainfo. As a result, my program relinquishes control when it tries to click the mouse. Any help? I'm sure someone has already accomplished this, but I can't seem to find any references. :(( -Jeff

    C 1 Reply Last reply
    0
    • C carp

      What is the best way to differentiate the mouse movements I call in my program (using SendInput or SetCursorPos) from other mouse movement messages? I'm using a system wide Mouse hook in a .dll that receives all mouse messages / movements and I want to distinguish mouse movements as a result of the physical mouse as different from the mouse movements and clicks I send to Windows through my program. My program moves the mouse around using SendInput and SetCursorPos and clicks using mouse_event. I want my program to relinquish control of the mouse when the user moves the physical mouse. How can I tell the difference in a system wide hook? I've tried embedding dwextrainfo into the movement and click calls that my program makes to tell them apart from the other messages, but my program calls seem to generate other, additional and simultaneous messages that do not contain the dwextrainfo. As a result, my program relinquishes control when it tries to click the mouse. Any help? I'm sure someone has already accomplished this, but I can't seem to find any references. :(( -Jeff

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I suspect you'd need to set a flag in the program you're sending messages to, so it knows they are from you. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002

      C 1 Reply Last reply
      0
      • C Christian Graus

        I suspect you'd need to set a flag in the program you're sending messages to, so it knows they are from you. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002

        C Offline
        C Offline
        carp
        wrote on last edited by
        #3

        Well, that's no help! If it were that simple, I wouldn't be asking about it. Your signature is comical in it's irony! What I've learned so far and what my next questions are: _____________________________________ The short answer is that you can not distinguish messages that are a result of physical mouse movements from those that are a result of SendInput or mouse_event calls. They get the same kind of handling by the operating system. Sent and posted messages on the other hand, can be distinguished from hardware input events and mouse_event messages, as they are appended to different queues in the thread. OK, so how should I send/post messages (instead of using SendInput/mouse_event ) to control the mouse... And how do I distinguish the messages in my system wide mouse hook? Or should I say system wide message hook? WH_MOUSE vs. WH_GETMESSAGE: which can access the correct information to make a determination? (How do I access the queues and thread information?)

        C 1 Reply Last reply
        0
        • C carp

          Well, that's no help! If it were that simple, I wouldn't be asking about it. Your signature is comical in it's irony! What I've learned so far and what my next questions are: _____________________________________ The short answer is that you can not distinguish messages that are a result of physical mouse movements from those that are a result of SendInput or mouse_event calls. They get the same kind of handling by the operating system. Sent and posted messages on the other hand, can be distinguished from hardware input events and mouse_event messages, as they are appended to different queues in the thread. OK, so how should I send/post messages (instead of using SendInput/mouse_event ) to control the mouse... And how do I distinguish the messages in my system wide mouse hook? Or should I say system wide message hook? WH_MOUSE vs. WH_GETMESSAGE: which can access the correct information to make a determination? (How do I access the queues and thread information?)

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          carp wrote: Well, that's no help! If it were that simple, I wouldn't be asking about it. It IS that simple. carp wrote: The short answer is that you can not distinguish messages that are a result of physical mouse movements from those that are a result of SendInput or mouse_event calls. They get the same kind of handling by the operating system. Correct - there is only one way for a program to respond to mouse movement, regardless of how the message got there. carp wrote: OK, so how should I send/post messages (instead of using SendInput/mouse_event ) to control the mouse... Use ::SendMessage and create messages with values of WM_USER, WM_USER+1, etc. carp wrote: And how do I distinguish the messages in my system wide mouse hook? All messages have a value, you'd #define your own. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups