Can anyone tell me how to use api calls to retrieve the clicking of the mouse? Or is it impossible?
Printable View
Can anyone tell me how to use api calls to retrieve the clicking of the mouse? Or is it impossible?
you can detect Mouseclicks pretty easily using a function that you would never think of, due to its name.
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Command1_Click()
Dim KeyState As Integer
Do While DoEvents > 0
KeyState = GetAsyncKeyState(vbKeyLButton)
Debug.Print KeyState
If (KeyState And &HF000) <> 0 Then MsgBox "Mouse1"
KeyState = GetAsyncKeyState(vbKeyRButton)
If (KeyState And &HF000) <> 0 Then MsgBox "Mouse2"
KeyState = GetAsyncKeyState(vbKeyMButton)
If (KeyState And &HF000) <> 0 Then MsgBox "Mouse3"
Loop
End Sub