by Seth Mayberry (1 Submission)
Category: Windows API Call/Explanation
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Thu 17th May 2007
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
How to use SendInput to send mouse clicks
API Declarations
Public dx As Integer
Public dy As Integer
Public mouseData As Integer
Public dwFlags As Integer
Public dwtime As Integer
Public dwExtraInfo As Integer
End Structure
Public Structure INPUT_TYPE
Public dwType As Integer
Public xi As MOUSEINPUT
End Structure
Private Declare Function SendInput Lib "user32.dll" (ByVal nInputs As Integer, ByRef pInputs As INPUT_TYPE, ByVal cbSize As Integer) As Integer
Private Const INPUT_MOUSE = 0
Private Const INPUT_KEYBOARD = 1
Private Const INPUT_HARDWARE = 2
Const M_MOVE = &H1
Const M_LD = &H2
Const M_LU = &H4
Dim inputEvents(0) As INPUT_TYPE
inputEvents(0).xi.dx = 0
inputEvents(0).xi.dy = 0
inputEvents(0).xi.mouseData = 0
inputEvents(0).xi.dwFlags = M_MOVE + M_LD + M_LU
inputEvents(0).xi.dwtime = 0
inputEvents(0).xi.dwExtraInfo = 0
inputEvents(0).dwType = INPUT_MOUSE
SendInput(1, inputEvents(0), Len(inputEvents(0)))
SetCursorPos(xyC)
End Sub