VB.NET – Simulate left mouse click in another app



VB.NET – Simulate left mouse click in another app

VB.NET - Simulate left mouse click in another app

Simple tutorial to simulate left mouse click in another app in VB.NET. Left-clicks are simulated in Windows calculator to add numbers

Const MOUSEEVENTF_LEFTDOWN As UInteger = &H2
Const MOUSEEVENTF_LEFTUP As UInteger = &H4

Public Declare Sub mouse_event Lib “user32” (ByVal dwFlags As UInteger, ByVal dx As UInteger, ByVal dy As UInteger, ByVal dwData As UInteger, ByVal dwExtraInfo As Integer)

Public Sub LeftClick()
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
Thread.Sleep(100) ‘Wait required
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub

Comments are closed.