Hi,
I am trying to find out how I can detect the mouseup on a form that belongs to another application. I can detect the left key via GetAsyncKeyState but haven't come across any code to detect the mouseup.
Any ideas?
Thanks,
Rob
Printable View
Hi,
I am trying to find out how I can detect the mouseup on a form that belongs to another application. I can detect the left key via GetAsyncKeyState but haven't come across any code to detect the mouseup.
Any ideas?
Thanks,
Rob
You can only detect the "MouseDown's" with GetAsyncKeyState. If you want to detect a MouseUp, you'd have to subclass the App.
You can detect a global MouseUp by Tracking the return value of the same GetAsyncKeyState() API function, i.e.Code:Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 10
End Sub
Private Sub Timer1_Timer()
Static bDown As Boolean
If GetAsyncKeyState(vbLeftButton) < 0 Then
' Log that the Mouse was pressed.
bDown = True
Else
' When the mouse is no longer depressed and it was previously, a Mouse Up must have occured.
If bDown Then Debug.Print "Mouse Up"
bDown = False
End If
End Sub
Actually, you can use a mouse hook instead, that means you don't need to use a timer to repeatedly check for the mouse button states. search on Setwindowhookex and you'll find out.