Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Oct 8th, 2003 04:04 AM Post subject: Detect KeyPress System Wide |
|
|
You'll need to add a timer named tmrKey and watch the debug window... Also detects mouse clicks!
| Code: | Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Dim k As Long
For k = 0 To 255
GetAsyncKeyState k
Next
End Sub
Private Sub tmrKey_Timer()
Dim k As Long, bAny As Boolean
For k = 0 To 255
If GetAsyncKeyState(k) Then
bAny = True
Exit For
End If
Next
If bAny Then
Debug.Print "Key " & Chr$(k) & " pressed" 'This won't show ctrl, alt presses but it still detects them...
End If
End Sub |
|
|