GetAsyncKeyState()& 0x8000f

GetAsyncKeyState函数功能:读取的是物理键状态,也是就是不管你怎么鼠标键盘映射,它只读取实际的按键状态。MSDN上给出了例子很恰当For example, the call GetAsyncKeyState(VK_LBUTTON) always returns the state of the left physical mouse button, regardless of whether it is mapped to the left or right logical mouse button.也就是说如果你重新设置了映射,GetAsyncKeyState还是只读取物理状态

GetAsyncKeyState的返回值:表示两个内容,一个是最高位bit的值,代表这个键是否被按下,按下为1,抬起为0;一个是最低位

bit的值,在windowsCE下要忽略(参考自MSDNIf the most significant bit is set, the key is down. The least significant

bit is not valid in Windows CE, and should be ignored.)

 
note:
GetAsyncKeyState('M')& 0x8000f // 要大写M, f的意思是float的意思

posted on 2011-10-01 18:30 メmarsメ 阅读(1415) 评论(3)  编辑 收藏 引用 所属分类: 点滴积累

评论

# re: GetAsyncKeyState()& 0x8000f 2012-06-27 14:00 メmarsメ

32位机子上没问题 64位机子不知道会不会默认符号扩展成64位的@麻子
  回复  更多评论   

# re: GetAsyncKeyState()& 0x8000f 2012-10-26 10:51 strike

float类型能进行 & 操作?你试试  回复  更多评论   

# re: GetAsyncKeyState()& 0x8000f 2014-04-01 13:41 豪臻

不会的,返回值是SHORT类型,不会扩展,已测试证明  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜