Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Jun 24, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

MoveMouseCursor - Move the mouse to given coordinates

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, _
    ByVal Y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, _
    lpPoint As POINTAPI) As Long

' Mouse the mouse cursor.
' If a window handle is passed, the coordinates
' are considered to be relative to that window's client area,
' otherwise they are considered to be relative to the screen.
' In all cases, coordinates are in pixels

Sub MoveMouseCursor(ByVal X As Long, ByVal Y As Long, _
    Optional ByVal hWnd As Long)
    If hWnd = 0 Then
        SetCursorPos X, Y
        Dim lpPoint As POINTAPI
        lpPoint.X = X
        lpPoint.Y = Y
        ClientToScreen hWnd, lpPoint
        SetCursorPos lpPoint.X, lpPoint.Y
    End If
End Sub
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date