# VBForums CodeBank > CodeBank - Visual Basic .NET >  Simulate Mouse Click

## Emcrank

Ok so i struggled to find this for days, then i did. Im posting it here so other people can find it. 
*Instructions*
*1. Put this code into your project*

VB.NET Code:
Private Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As IntPtr)    Private Sub PerformMouseClick(ByVal LClick_RClick_DClick As String)        Const MOUSEEVENTF_LEFTDOWN As Integer = 2        Const MOUSEEVENTF_LEFTUP As Integer = 4        Const MOUSEEVENTF_RIGHTDOWN As Integer = 6        Const MOUSEEVENTF_RIGHTUP As Integer = 8        If LClick_RClick_DClick = "RClick" Then            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, IntPtr.Zero)            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, IntPtr.Zero)        ElseIf LClick_RClick_DClick = "LClick" Then            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)        ElseIf LClick_RClick_DClick = "DClick" Then            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, IntPtr.Zero)            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, IntPtr.Zero)        End If    End Sub
*2. THEN Just Call either of the below depending on which click you want*
_-LClick = Left Mouse Click
-RClick = Right Mouse Click
-DClick = Double Left Mouse Click_

VB.NET Code:
PerformMouseClick("LClick")

VB.NET Code:
PerformMouseClick("RClick")

VB.NET Code:
PerformMouseClick("DClick")

----------

