I'm guessing you'll want to record mouse clicks too. Since your form
doesn't have focus, it doesn't receive mouse events; therefore you have
to poll the "key state" of the mouse buttons repeatedly and rapidly,
else you'll miss clicks:
Const VK_LBUTTON = &H1 ' left-mousebutton
Const VK_RBUTTON = &H2 ' right-mousebutton
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As
Int32) As Int32
Function MyGetKeystate(ByVal WhichKey As Int32) As Boolean
' Returns the status of a key.
' Pass one of the VK_* constants defined above, or any key value.
If GetAsyncKeyState(WhichKey) And &H8000 Then MyGetKeystate = True
End Function
Function LeftButton() As Boolean
LeftButton = MyGetKeystate(VK_LBUTTON)
End Function
Function Get RightButton() As Boolean
RightButton = MyGetKeystate(VK_RBUTTON)
End Function
It should also be possible to hook into the Windows mouse handlers and
avoid polling, but that's beyond me.