当前位置:去问问>百科问答>急!急!急!谁知道c++里的GetAsyncKeyState到底怎么用啊?

急!急!急!谁知道c++里的GetAsyncKeyState到底怎么用啊?

2024-11-28 07:36:26 编辑:zane 浏览量:538

急!急!急!谁知道c++里的GetAsyncKeyState到底怎么用啊?

的有关信息介绍如下:

急!急!急!谁知道c++里的GetAsyncKeyState到底怎么用啊?

下面是我的一点解释,“引号起来的内容注要意体会”,括号中的内容是我自己加的。例子是在测试程序具有键盘焦点的情况下进行的。原型:SHORT GetAsyncKeyState(int vKey);参数vKey是某个按键的虚拟码(很多虚拟码跟其ASCII码数值上相等,但不代表全部。)MSDN片段:The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.译文:函数GetAsyncKeyState确定在调用它时某个按键处于弹起还是按下的,以及此按键是否在上一次调用GetAsyncKeyState之后(“又”)按下过(重复也算按下)。MSDN片段:If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks. Windows NT/2000/XP: The return value is zero for the following cases: The current desktop is not the active desktopThe foreground thread belongs to another process and the desktop does not allow the hook or the journal record.Windows 95/98/Me: The return value is the global asynchronous key state for each virtual key. The system does not check which thread has the keyboard focus.Windows 95/98/Me: Windows 95 does not support the left- and right-distinguishing constants. If you call GetAsyncKeyState with these constants, the return value is zero. 译文:如果函数成功,则返回值指定此按键自上次上次调用GetAsyncKeyState后是否按下过,以及此按键当前是弹起的还是按下的。如果最高比特位被设置(就是被设为1),此按键就是按下的,如果最低位被设置,则此按键在上次调用GetAsyncKeyState之后(“又”)被按下过。但是你不应该依赖于之前的(按键)行为。更多的信息请看备注。Windows NT/2000/XP: 以下情况返回值为0* 当前桌面不是活动桌面(你有多个桌面的时候就会发生。)* 前台线程属于其他的进程并且桌面不允许次拦截(hook,名词时具有钩或类似物品的含义,动词使具有使用这些物品时的动作的含义,我采用一个根式和理解的词汇,但还不是很准)或日志记录。Windows 95/98/Me: 返回值是每个虚拟键全局异步按键状态。系统不会校对那个线程拥有键盘焦点。Windows 95/98/Me: Windows 95 不支持左右鉴别值。如果你用这些(包含左右鉴别值的)常量去调用GetAsyncKeyState时返回值为0。举例:假设下载我把A按住,调用GetAsyncKeyState('A')返回0x8001在按键重复之前放掉A,调用GetAsyncKeyState('A')返回0x0000又把A按住,又放掉,调用GetAsyncKeyState('A')返回0x0001又把A按住,调用GetAsyncKeyState('A')返回0x8001在按键重复开始后放掉A,调用GetAsyncKeyState('A')返回0x0001又调用GetAsyncKeyState('A')返回0x0000

版权声明:文章由 去问问 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.qwenw.com/answer/432692.html
热门文章