|
-
Mar 21st, 2003, 03:28 AM
#1
Thread Starter
Hyperactive Member
Key is down or up? *resolved*
Following code is in the timer with interval set to 100
VB Code:
If GetAsyncKeyState(VK_F12) Then
....
num = num + 1
end if
The problem is if i keep F12 down without releasing it, num will increase by 1 every 100 milliseconds. Is there anyway to make it work so num = num + 1 will ONLY execute when F12 has been released, so if I press F12 when num = 0, num will stay 0 until I depress F12, and when I press it again num will equal to 1, and so on. With each key press num will increase by 1, but with continuous key press, num will not change.
Last edited by Dmitri K; Mar 21st, 2003 at 07:57 PM.
-
Mar 21st, 2003, 03:38 AM
#2
Fanatic Member
Without checking the code.
Could you do it in the key up event. start the timer when the keyup activates
Maybe be totally wrong.
Cheers
-
Mar 21st, 2003, 04:28 AM
#3
Thread Starter
Hyperactive Member
No, unfortunately no. I need to track global keypress, not just application's process.
-
Mar 21st, 2003, 05:17 AM
#4
Fanatic Member
-
Mar 21st, 2003, 05:25 AM
#5
Frenzied Member
A timer is not a good way to track a global keypress - what happens if they press it twice between timer clicks, and the timer code is quite a heavy drain on the system.
If you want to see all the keypresses system wide, install a system wide journal or low level keyboard hook as per this example or if you just want to be notified when a given key is pressed system-wide then use the RegisterHotkey API call as in the MCL Global Hotkey control
-
Mar 21st, 2003, 07:57 PM
#6
Thread Starter
Hyperactive Member
Well Hotkey sounds great, but I stayed away from any 3rd party controls thruout the project, I don't want to use them now either.
Thanks
-
Mar 22nd, 2003, 06:17 AM
#7
Frenzied Member
but I stayed away from any 3rd party controls thruout the project, I don't want to use them now either.
Then I'd suggest you download the source code and add it to your project thus have no external dependencies...
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
|