使用多线程计算同时按键事件的开始和结束时间 [英] Calculate start and endtime of simultaneous key event using multithreading

查看:253
本文介绍了使用多线程计算同时按键事件的开始和结束时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用多线程计算同时发生的按键事件的开始和结束时间,我需要保存基于开始和结束时间自动执行按键事件的时间.

假设我在开始时间1和结束时间8和
执行keyNo1的keyDown 在开始时间2和结束时间10处KeyNo2的键入
在开始时间1和结束时间3处KeyNo3的KeyDown,如此类推.

如何在c ++中实现此功能,我需要此示例代码.

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.

推荐答案

捕获键事件并将开始时间存储在使用键号作为索引的表中.在keyup事件中,您可以计算(currentTime-startTime = elapsedTime).困难是什么?
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?


信息不足.
如果您的应用程序没有视图,则应从键盘挂钩开始.您可以在wm_keydown窗口消息上获取开始时间,并在wm_keyup上获取结束时间.
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.


这篇关于使用多线程计算同时按键事件的开始和结束时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆