Results 1 to 2 of 2

Thread: moving the mousepointer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111

    Question moving the mousepointer

    Is there a way to move the mousepointer with code? When it is double-clicked, it moves to a button? Thanks.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
    2. Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    3.  
    4. Private Type RECT
    5.         Left As Long
    6.         Top As Long
    7.         Right As Long
    8.         Bottom As Long
    9. End Type
    10.  
    11. Private Sub MoveMouse(ByVal hWnd As Long)
    12.    
    13.     Dim lpRect As RECT
    14.    
    15.     GetWindowRect hWnd, lpRect
    16.  
    17.     SetCursorPos lpRect.Left + (lpRect.Right - lpRect.Left) \ 2, _
    18.         lpRect.Top + (lpRect.Bottom - lpRect.Top) \ 2
    19.  
    20. End Sub
    21.  
    22. 'Move Mouse
    23.  
    24. 'Usage:   Call MoveMouse(Command1.hWnd)
    Change Command1 to the appropriate name. NOTE: This only works with controls have have a hWnd property!

Posting Permissions

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



Click Here to Expand Forum to Full Width