hi,
is it possible to know whether any key is pressed in the
form using window API. If yes then how???
And after that is detected I want to call a function Which
will do certain activity.
Please tell me how to do it
thx
[email protected]
Printable View
hi,
is it possible to know whether any key is pressed in the
form using window API. If yes then how???
And after that is detected I want to call a function Which
will do certain activity.
Please tell me how to do it
thx
[email protected]
use GetAsyncKeyState and poll, but why not just use the Form_KeyPress Event with the KeyPreview property set to True?
Here is an example of how to use the GetAsyncKeyState api:
Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim iKey As Integer
For iKey = 0 To 255
If GetAsyncKeyState(iKey) Then Caption = "KeyCode: " & iKey & " was pressed."
Next
End Sub
Numbers 2 and below represent a NullCharacter, left mouse and right mouse respectively. If you don't want to capture them, simply start from 3.
Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim iKey As Integer
For iKey = 3 To 255
If GetAsyncKeyState(iKey) Then Caption = "KeyCode: " & iKey & " was pressed."
Next
End Sub