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确定在调用它时某个按键处于d起还是按下的,以及此按键是否在上一次调用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 behaviorfor 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 desktop
The 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后是否按下过,以及此按键当前是d起的还是按下的。如果最高比特位被设置(就是被设为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
#include<bits/stdc++.h>using namespace std
int main(){
for(int ii++){
if(cin>>E) cout<<1
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)