Windows 95/98: Windows 95 does not support the left- and right-distinguishing constants. If you call GetAsyncKeyState with these constants, the return value is zero.BOOL GetKeyboardState( PBYTE lpKeyState // pointer to array to receive status data ); 可以支持区分左右 VK_LSHIFT VK_RSHIFT VK_LCONTROL VK_RCONTROL VK_LMENU VK_RMENU
msdn上邊沒有說GetKeyState的限制,只是說,如果要得到所有的虛擬鍵信息,則用GetKeyboardState,所以,用checkyvc6的方法應該可以。 msdn如下:An application can also use the following virtual-key code constants as values for nVirtKey to distinguish between the left and right instances of those keys. VK_LSHIFT VK_RSHIFT VK_LCONTROL VK_RCONTROL VK_LMENU VK_RMENU These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
PBYTE lpKeyState // pointer to array to receive status data
);
可以支持区分左右
VK_LSHIFT VK_RSHIFT
VK_LCONTROL VK_RCONTROL
VK_LMENU VK_RMENU
谢谢!
你试过吗?这个问题是我在编写一个输入法出来的,我用应用程序传给输入法的键盘状态数组进行检测也不能区分大小写,我以为键盘状态数组应该和GetKeyboardState得到的数据相同。
我现在还没有试,成功了就给分。
而且最后的结论是在98下用GetKeyState无法区分左右键。
我用GetKeyboardState(BYTE *buf)后,测试buf[VK_LSHIFT]及buf[VK_RSHIFT]结果都是0,但测试buf[VK_SHIFT]时,当我按下left shift时得到0x81,右键时得到0x80,我也不知道这样做安不安全。
不行啊!还有什么办法?
msdn如下:An application can also use the following virtual-key code constants as values for nVirtKey to distinguish between the left and right instances of those keys. VK_LSHIFT VK_RSHIFT
VK_LCONTROL VK_RCONTROL
VK_LMENU VK_RMENU
These left- and right-distinguishing constants are available to an application only through the GetKeyboardState, SetKeyboardState, GetAsyncKeyState, GetKeyState, and MapVirtualKey functions.
什么事件,只有实践才是最有说服力的。
因为我是做输入法,所以我问了一个做输入法的同行,他说他是通过加载键盘勾子实现的。
真不知道是不是只有这一个解决办法?