GetAsyncKeyState(i) / Key
If any key is pressed on the keyboard I would like the application to say apple.
Code:
Private Sub Timer1_Timer()
Dim KeyResult As Integer
Dim i As Byte
For i = 1 To 254
KeyResult = GetAsyncKeyState(i)
If KeyResult = -32767 Then
Select Case i
Case i < 255
MsgBox "apple"
End Select
End If
Next
End Sub
Re: GetAsyncKeyState(i) / Key
Got it to work like this but anyway to do it without listbox?
Code:
Private Sub Timer1_Timer()
Dim KeyResult As Integer
Dim i As Byte
For i = 1 To 254
KeyResult = GetAsyncKeyState(i)
If KeyResult = -32767 Then
Select Case List1.ListIndex
Case 0
If i < 255 Then
MsgBox "apple"
End If
End Select
End If
Next
End Sub
Re: GetAsyncKeyState(i) / Key
Nvm got it. Just got rid of case select and did it like this. Thanks anyways
Code:
Private Declare Function GetAsyncKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim KeyResult As Integer
Dim i As Byte
For i = 1 To 254
KeyResult = GetAsyncKeyState(i)
If KeyResult = -32767 Then
If i < 255 Then
MsgBox "apple"
Else
End If
End If
Next
End Sub