Thank you for visiting → Compete For ← If you find anything useful leave me a comment and share. Interested in Arduino, C#, Unity3D, Game Creation, VB.NET, learning and most important of all Sharing!.
Close Notification
Open Notification

WinForm Detect Mouse Click

WinForm Detect Mouse Click
Option Explicit On
Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
    Private Const VK_LBUTTON = &H1
    Private Const VK_RBUTTON = &H2

    Public Function isClicked()
        If GetAsyncKeyState(VK_LBUTTON) Then
            Return "Left Click"
        ElseIf GetAsyncKeyState(VK_RBUTTON) Then
            Return "Right Click"
        End If
    End Function

    Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
        Label1.Text = isClicked()
    End Sub
End Class

For a big list of GetAsynKeyStates click here

Leave a reply