VB Code:
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub MoveMouse(ByVal hWnd As Long)
Dim lpRect As RECT
GetWindowRect hWnd, lpRect
SetCursorPos lpRect.Left + (lpRect.Right - lpRect.Left) \ 2, _
lpRect.Top + (lpRect.Bottom - lpRect.Top) \ 2
End Sub
'Move Mouse
'Usage: Call MoveMouse(Command1.hWnd)
Change Command1 to the appropriate name. NOTE: This only works with controls have have a hWnd property!