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. Send mouse message

Send mouse message

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelpquestion
7 Posts 4 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.
  • L Offline
    L Offline
    leenmie
    wrote on last edited by
    #1

    I'm trying to send mouse message to a application programmatically . I use win32 API SendMessage() to MS Paint (just 4 a test) to draw : SendMessage(hwnd_paint,WM_LBUTTONDOWN,0,position). There was no error but nothing happened. Is there something wrong ?

    R S O 4 Replies Last reply
    0
    • L leenmie

      I'm trying to send mouse message to a application programmatically . I use win32 API SendMessage() to MS Paint (just 4 a test) to draw : SendMessage(hwnd_paint,WM_LBUTTONDOWN,0,position). There was no error but nothing happened. Is there something wrong ?

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      1. Manually do the mouse event and using spy++ try to find out the appropriate values of LPARAM and WPARAM 2. After a lbuttondown message, also post a lbutton up message. Regards, Rajesh R. Subramanian You have an apple and me too. We exchange those and We have an apple each. You have an idea and me too. We exchange those and We have two ideas each.

      1 Reply Last reply
      0
      • L leenmie

        I'm trying to send mouse message to a application programmatically . I use win32 API SendMessage() to MS Paint (just 4 a test) to draw : SendMessage(hwnd_paint,WM_LBUTTONDOWN,0,position). There was no error but nothing happened. Is there something wrong ?

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        To fake input you should use the SendInput function. See here for details (talks about keyboard input but a lot of what is mentioned still applies). Steve

        1 Reply Last reply
        0
        • L leenmie

          I'm trying to send mouse message to a application programmatically . I use win32 API SendMessage() to MS Paint (just 4 a test) to draw : SendMessage(hwnd_paint,WM_LBUTTONDOWN,0,position). There was no error but nothing happened. Is there something wrong ?

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          Check out the position. Maybe it's not on the drawing canvas.

          Jesus Loves:rose:

          --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

          L 1 Reply Last reply
          0
          • O Owner drawn

            Check out the position. Maybe it's not on the drawing canvas.

            Jesus Loves:rose:

            --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

            L Offline
            L Offline
            leenmie
            wrote on last edited by
            #5

            I used Spy++ to get parameter, and try to SendMessage. But it dosent work. I cant understand what happened ????

            O 1 Reply Last reply
            0
            • L leenmie

              I used Spy++ to get parameter, and try to SendMessage. But it dosent work. I cant understand what happened ????

              O Offline
              O Offline
              Owner drawn
              wrote on last edited by
              #6

              Try replacing WM_LBUTTONDOWN with WM_MOUSEMOVE. And I think you should pass something for WPARAM, just pass MK_LBUTTON. This means left mouse button is down and we are dragging the mouse. Equivalent to drawing in MS-Paint.

              Jesus Loves:rose:

              --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

              1 Reply Last reply
              0
              • L leenmie

                I'm trying to send mouse message to a application programmatically . I use win32 API SendMessage() to MS Paint (just 4 a test) to draw : SendMessage(hwnd_paint,WM_LBUTTONDOWN,0,position). There was no error but nothing happened. Is there something wrong ?

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #7

                Using SendMessage or PostMessage message may or may not work, it depends on the program. As I mentioned the SendInput API is specifically designed for faking input. Here are some reasons the SendMessage/PostMessage technique may not work: - The program calls the GetMessagePos to get the coordinated of the mouse when a message was posted. - The program calls the GetAsyncKeyState to check for mouse buttons. In short, the SendMessage/PostMessage may work, but then again it may not: it depends on how the program performs its input. Steve

                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