Move Mouse
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Move Mouse

  1. #1
    Join Date
    Jul 2011
    Posts
    10

    Move Mouse

    Hello!

    How can I move the mouse to different locations in another application. Currently, I used HDC and HWND to get my window's handle. (Also FindWindow). So, is it possible to like MouseMove(HDC, 5,5)?

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Move Mouse

    have a search for these apis:

    GetCursorPos Lib "User32.dll"

    SetCursorPos Lib "User32.dll"

    mouse_event Lib "user32

    GetAsyncKeyState Lib "user32"
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Move Mouse

    BY the way, you could find this interesting: a hook for windows and exactly for the mouse:
    http://support.microsoft.com/kb/319524
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    Jul 2011
    Posts
    10

    Re: Move Mouse

    thanks for the info. can you or someone post an example on how to use the above api with a hwnd/hdc.

    here is my current code:

    Code:
    Dim hWnd As Integer = FindWindow(vbNullString, "Untitled - Notepad")
            Dim hDC As IntPtr
            SetForegroundWindow(hWnd)
            hDC = GetDC(hWnd)
            'I would like to move the mouse here. MouseMove(HDC/HWND,X,Y)
    It looks possible lol. thanks for all the help!

  5. #5
    Join Date
    Jul 2011
    Posts
    10

    Re: Move Mouse

    anyone xD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center