Click here to Skip to main content
15,898,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need Calculate start and endtime of simultaneous key event using multithreading which i need to save perform the key events based on start and endtimes automatically.

suppose i perform keyDown of keyNo1 at start time 1 and endtime 8 and
Keyup of KeyNo2 at Starttime 2 and EndTime 10
KeyDown of KeyNo3 at Starttime 1 and Endtime 3 so on.

How to implement this in c++ and I need a sample code of this.
Posted

Trap the key events and store the start time in a table using the keynumber as index. At the keyup event you can calculate (currentTime - startTime = elapsedTime). What is the difficulty?
 
Share this answer
 
Comments
Espen Harlinn 9-Feb-12 9:17am    
Good point :)
Sergey Alexandrovich Kryukov 9-Feb-12 17:52pm    
Sure, a 5.
--SA
chaiein 9-Feb-12 23:16pm    
How to use this in multi threading?
chaiein 9-Feb-12 23:18pm    
difficulty now is how to implement it using multithreading concept.
chaiein 9-Feb-12 23:19pm    
if multithreading is not used then can we get desired output using keynumber as the index of some array which is equal to size of the number of keys in keyboard?
Not enough information.
if your application dont have view may be you should start with keyboard hooking. You can get start time on wm_keydown window message and end time on wm_keyup.
 
Share this answer
 
Comments
chaiein 9-Feb-12 23:51pm    
So please tell me how to check whether that particular key is pressed.
if i press the same key more than once also all elapsed times should be stored vector array.
Mohibur Rashid 10-Feb-12 1:01am    
please check
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646280(v=vs.85).aspx
and
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

Still we dont know who would receive the key stroke.
chaiein 10-Feb-12 1:13am    
keystroke is received by view that i have created a piano where each key of piano corresponds to a keys in keyboard.
chaiein 10-Feb-12 1:15am    
thanks for the link :)
chaiein 10-Feb-12 1:20am    
using the link you i have posted i can check whether that key is pressed or not. Instead can you tell me how can we get to know directly without checking true or false just something like getKeyNo()...Is there any Standard function?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900