|
-
Aug 23rd, 2000, 07:57 AM
#1
Thread Starter
New Member
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]
-
Aug 23rd, 2000, 08:26 PM
#2
Fanatic Member
use GetAsyncKeyState and poll, but why not just use the Form_KeyPress Event with the KeyPreview property set to True?
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 23rd, 2000, 08:33 PM
#3
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
-
Aug 24th, 2000, 08:01 AM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|