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. still moving the mouse

still moving the mouse

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 Posts 5 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.
  • G Offline
    G Offline
    Grimes
    wrote on last edited by
    #1

    Hi there, I'm in need of help to move the mouse to any position on my program's window. I got help, and was told to use the SetCursorPos() function. This moves the mouse to a point on the screen and not on my window. How can I get my window's top and left position so that I can use SetCursorPos(window.left + x, window.top + y) //x and y are the position on //my program's window ? Are there better ways of doing this? thanx...

    KOM UIT DAAAAA!!!

    N R _ C 4 Replies Last reply
    0
    • G Grimes

      Hi there, I'm in need of help to move the mouse to any position on my program's window. I got help, and was told to use the SetCursorPos() function. This moves the mouse to a point on the screen and not on my window. How can I get my window's top and left position so that I can use SetCursorPos(window.left + x, window.top + y) //x and y are the position on //my program's window ? Are there better ways of doing this? thanx...

      KOM UIT DAAAAA!!!

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      first take ur window's cordinate using the GetWindowRect function.then move the cursor to that position. CRect WindowRect; GetWindowRect( WindowRect ); SetCursorPos(WindowRect.left + x, WindowRect .top + y)

      nave

      1 Reply Last reply
      0
      • G Grimes

        Hi there, I'm in need of help to move the mouse to any position on my program's window. I got help, and was told to use the SetCursorPos() function. This moves the mouse to a point on the screen and not on my window. How can I get my window's top and left position so that I can use SetCursorPos(window.left + x, window.top + y) //x and y are the position on //my program's window ? Are there better ways of doing this? thanx...

        KOM UIT DAAAAA!!!

        R Offline
        R Offline
        Rinu_Raj
        wrote on last edited by
        #3

        You may use GetWindowRect(...) to Get the window co-ordinates Also ClipCursor(...) to confine the cursor to a rectangular area on the screen Rinu Raj

        1 Reply Last reply
        0
        • G Grimes

          Hi there, I'm in need of help to move the mouse to any position on my program's window. I got help, and was told to use the SetCursorPos() function. This moves the mouse to a point on the screen and not on my window. How can I get my window's top and left position so that I can use SetCursorPos(window.left + x, window.top + y) //x and y are the position on //my program's window ? Are there better ways of doing this? thanx...

          KOM UIT DAAAAA!!!

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #4

          Grimes wrote:

          mouse to any position on my program's window.

          Try ScreenToClient(LPPOINT lpPoint);

          Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

          1 Reply Last reply
          0
          • G Grimes

            Hi there, I'm in need of help to move the mouse to any position on my program's window. I got help, and was told to use the SetCursorPos() function. This moves the mouse to a point on the screen and not on my window. How can I get my window's top and left position so that I can use SetCursorPos(window.left + x, window.top + y) //x and y are the position on //my program's window ? Are there better ways of doing this? thanx...

            KOM UIT DAAAAA!!!

            C Offline
            C Offline
            Chipperm
            wrote on last edited by
            #5

            You want to use the function GetWindowRect to get the window coordinates. From that you can then call SetCursorPos and apply the correct offsets. x_coord+=x_offset; y_coord+=y_offset; Search for GetWindowRect on google and it should take you to the msdn page for that function.

            Chipper Martin

            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