Public Class CustomCursor
Private Declare Sub SetCursorPos Lib "User32" (ByVal X As Integer, ByVal Y As Integer)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHYDOWN = &H6
Private Const MOUSEEVENTF_RIGHTUP = &H8
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Public Function MoveCursor(ByVal X As Integer, ByVal Y As Integer) As Single
Try
Dim IntX As Integer = CleanInteger(X, Form1.Location.X)
Dim IntY As Integer = CleanInteger(Y, Form1.Location.Y)
If Cursor.Position.X = IntX Then
Else
If Cursor.Position.X < IntX Then
SetCursorPos(Cursor.Position.X + 1, Cursor.Position.Y)
ElseIf Cursor.Position.Y > IntX Then
SetCursorPos(Cursor.Position.X - 1, Cursor.Position.Y)
End If
End If
If Cursor.Position.Y = IntY Then
Else
If Cursor.Position.Y < IntY Then
SetCursorPos(Cursor.Position.X, Cursor.Position.Y + 1)
ElseIf Cursor.Position.Y > IntY Then
SetCursorPos(Cursor.Position.X, Cursor.Position.Y - 1)
End If
End If
If Cursor.Position.X = IntX Then
If Cursor.Position.Y = IntY Then
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Exit Function
End If
End If
SpeedMove(X, Y)
Catch
End Try
End Function
Public Function CleanInteger(ByVal Int As Integer, ByVal Target As Integer) As String
Dim i As Integer
i = Target + Int
Return i
End Function
Public Function SpeedMove(ByVal X As Integer, ByVal Y As Integer) As Single
Try
Dim IntX As Integer = CleanInteger(X, Form1.Location.X)
Dim IntY As Integer = CleanInteger(Y, Form1.Location.Y)
If Cursor.Position.X = IntX Then
Else
If Cursor.Position.X < IntX Then
SetCursorPos(Cursor.Position.X + 1, Cursor.Position.Y)
ElseIf Cursor.Position.Y > IntX Then
SetCursorPos(Cursor.Position.X - 1, Cursor.Position.Y)
End If
End If
If Cursor.Position.Y = IntY Then
Else
If Cursor.Position.Y < IntY Then
SetCursorPos(Cursor.Position.X, Cursor.Position.Y + 1)
ElseIf Cursor.Position.Y > IntY Then
SetCursorPos(Cursor.Position.X, Cursor.Position.Y - 1)
End If
End If
If Cursor.Position.X = IntX Then
If Cursor.Position.Y = IntY Then
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Exit Function
End If
End If
MoveCursor(X, Y)
Catch
End Try
End Function
End Class