Visual Basic Mauszustand abfragen?

2 Antworten

Option Explicit
 
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
 
Private Sub Form_Load()
    Timer1.Interval = 250 ' less interval may cause performance issues
    Timer1.Enabled = True
End Sub
 
Private Sub Timer1_Timer()
    ' Checking left mouse button.
    If GetAsyncKeyState(1) = 0 Then
        Me.Caption = "L up"
    Else
        Me.Caption = "L down"
    End If
    
'    ' Checking right mouse button.
'    If GetAsyncKeyState(2) = 0 Then
'        Me.Caption = "R up"
'    Else
'        Me.Caption = "R down"
'    End If
End Sub
Woher ich das weiß:Studium / Ausbildung – Informatikstudent