|
-
Nov 12th, 2000, 05:02 PM
#1
Thread Starter
Hyperactive Member
I'm wondering how i can make something to tell if a key or combination of keys are pressed while a program is running. The form does not have to be the top window. Like if you are on you computer, where ever you are, with your program running, and you hit CTRL + ESC, then do something. Or any specific keys. How Would You Do This?? Please Help.
-
Nov 12th, 2000, 05:19 PM
#2
Use the GetAsyncKeyState API. Add the following to a Form with a Timer.
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
If GetAsyncKeyState(vbKeyControl) And GetAsyncKeyState(vbKeyEscape) Then MsgBox "CTRL+ESC was pressed"
End Sub
-
Nov 12th, 2000, 05:20 PM
#3
transcendental analytic
Place a timer on the form paste this code:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_CONTROL = &H11
Private Const VK_ESCAPE = &H1B
Private Sub Timer1_Timer()
If GetAsyncKeyState(VK_CONTROL) And GetAsyncKeyState(VK_ESCAPE) Then MsgBox "CTRL + ESC PRESSED"
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 12th, 2000, 07:24 PM
#4
The constants are already internally defined in VB, so you can omit them.
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
|