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. Moving The Mouse/Cursor Then Button Click ?

Moving The Mouse/Cursor Then Button Click ?

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 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.
  • F Offline
    F Offline
    Fritzables
    wrote on last edited by
    #1

    Hi all, I am partly through creating a console application that runs a Windows app. All this I have managed to perform, but the following I am unsure of. I now need to bring the form to the current view (which I have achieved), then put the mouse pointer in a certain position then simulate pressing the left mouse button. Can anyone suggest where I need to start looking to allow me to work this one out ? Pete

    D W J 3 Replies Last reply
    0
    • F Fritzables

      Hi all, I am partly through creating a console application that runs a Windows app. All this I have managed to perform, but the following I am unsure of. I now need to bring the form to the current view (which I have achieved), then put the mouse pointer in a certain position then simulate pressing the left mouse button. Can anyone suggest where I need to start looking to allow me to work this one out ? Pete

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Fritzables wrote:

      then put the mouse pointer in a certain position then simulate pressing the left mouse button.

      Is mouse_event() of any help here?


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      F 1 Reply Last reply
      0
      • F Fritzables

        Hi all, I am partly through creating a console application that runs a Windows app. All this I have managed to perform, but the following I am unsure of. I now need to bring the form to the current view (which I have achieved), then put the mouse pointer in a certain position then simulate pressing the left mouse button. Can anyone suggest where I need to start looking to allow me to work this one out ? Pete

        W Offline
        W Offline
        Walter_H
        wrote on last edited by
        #3

        i guess the right way would be the SendMessage function. use it with the parameter WM_LBUTTONUP. walter

        F 1 Reply Last reply
        0
        • D David Crow

          Fritzables wrote:

          then put the mouse pointer in a certain position then simulate pressing the left mouse button.

          Is mouse_event() of any help here?


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          F Offline
          F Offline
          Fritzables
          wrote on last edited by
          #4

          G'Day Dave, That sounds the GO, but what about getting the Mouse Cursor in the position I want ? Pete

          1 Reply Last reply
          0
          • W Walter_H

            i guess the right way would be the SendMessage function. use it with the parameter WM_LBUTTONUP. walter

            F Offline
            F Offline
            Fritzables
            wrote on last edited by
            #5

            Thanks Walter..... have a look at the reply I shot Dave. Pete

            1 Reply Last reply
            0
            • F Fritzables

              Hi all, I am partly through creating a console application that runs a Windows app. All this I have managed to perform, but the following I am unsure of. I now need to bring the form to the current view (which I have achieved), then put the mouse pointer in a certain position then simulate pressing the left mouse button. Can anyone suggest where I need to start looking to allow me to work this one out ? Pete

              J Offline
              J Offline
              John R Shaw
              wrote on last edited by
              #6

              I am not sure about a console application. In Windows the mouse pointer is called a ‘cursor’ and you can set the position by calling SetCursorPos(x,y). Note that if ClipCursor was used to limit its rectangular area of movement then it will remain in that area. After setting its position you can post the button-down and button-up messages, in that order, to simulate a button press & release.

              INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

              F 1 Reply Last reply
              0
              • J John R Shaw

                I am not sure about a console application. In Windows the mouse pointer is called a ‘cursor’ and you can set the position by calling SetCursorPos(x,y). Note that if ClipCursor was used to limit its rectangular area of movement then it will remain in that area. After setting its position you can post the button-down and button-up messages, in that order, to simulate a button press & release.

                INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                F Offline
                F Offline
                Fritzables
                wrote on last edited by
                #7

                Thanks John, Yep, got the cursor now moving all over the place using the Cursor->Position. I will now concentrate on the mouse clicking now. :-) Thanks again John. Pete

                J 1 Reply Last reply
                0
                • F Fritzables

                  Thanks John, Yep, got the cursor now moving all over the place using the Cursor->Position. I will now concentrate on the mouse clicking now. :-) Thanks again John. Pete

                  J Offline
                  J Offline
                  John R Shaw
                  wrote on last edited by
                  #8

                  You are welcome, Just a thought that this may come in handy, if do not have the have the handle to the button and have the handle to the parent then you can call ChildWindowFromPoint to get it. I guess that if you know its coordinates then you already have the handle; anyway I thought I would pass that along. John

                  INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

                  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