When I use the code below (got from a tutorial) it only sets the cursors X pos and not the Y pos. I've tried so many things to get this working and now I need some guidance. Thanks.
- Code: Select all
Public Class Form1
Private Structure POINTAPI
Dim X As Long
Dim Y As Long
End Structure
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, _
ByVal lpPoint As POINTAPI) As Long
Public Sub MoveMouseCursor(ByVal X As Long, ByVal Y As Long, _
Optional ByVal hWnd As Long = 0)
If hWnd = 0 Then
SetCursorPos(X, Y)
Else
Dim lpPoint As POINTAPI
lpPoint.X = X
lpPoint.Y = Y
ClientToScreen(hWnd, lpPoint)
SetCursorPos(lpPoint.X, lpPoint.Y)
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MoveMouseCursor(500, 500)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class


