Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C/C++;GetAsyncKeyState()键组合_C++_Windows_Api - Fatal编程技术网

C++ C/C++;GetAsyncKeyState()键组合

C++ C/C++;GetAsyncKeyState()键组合,c++,windows,api,C++,Windows,Api,我知道如何用一个键使用此功能,但如何用两个按键使用此功能 比如:GetAsyncKeyStat(VK_LBUTTON&&VK_RBUTTON) 您必须调用GetAsyncKeyState两次 //"And" the returns of GetAsyncKeyState //Then "and" the result with 0x8000 to get whether or not the Most Significant Bit is set bool bBothPressed = GetA

我知道如何用一个键使用此功能,但如何用两个按键使用此功能


比如:GetAsyncKeyStat(VK_LBUTTON&&VK_RBUTTON)

您必须调用
GetAsyncKeyState
两次

//"And" the returns of GetAsyncKeyState
//Then "and" the result with 0x8000 to get whether or not the Most Significant Bit is set
bool bBothPressed = GetAsyncKeyState(VK_LBUTTON) & GetAsyncKeyState(VK_RBUTTON) & 0x8000;

通常,如果要查询多个键,最好的答案是使用GetKeyboardState,它返回数组中每个虚拟键的状态,您可以直接高效地处理这些虚拟键。

。或者是实验性编程?在不理解标记真正含义的情况下排列标记。您应该非常小心地检查是否确实需要GetAsyncKeyState-如果您不完全理解GetKeyState和GetAsyncKeyState之间的区别,我建议您使用GetKeyState,因为您可能不需要GetAsyncKeyState—它不满足您的需要。如何测试最高有效位&0x8?我以为需要0xF000?是的,我的错,应该是0x8000。