[英]Check if ALT key is pressed
經過大量測試后,我無法記錄是否在C程序中使用GetAsyncKeyState按下了Alt鍵。 當我嘗試這個:
if (GetAsyncKeyState(VK_SHIFT))
// do something
它正常工作,但是當我嘗試這個
if (GetAsyncKeyState(VK_MENU))
// do something
沒用
所以我的問題是“如何記錄ALT?”。
提前致謝
我使用下面的代碼找出完全適合GetAsyncKeyState
的任何鍵的值,我認為ALT
鍵為18。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#if _WIN32_WINNT < 0x0500
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
using namespace std;
int main ()
{
char i;
for(i=8; i<190; i++)
{
if(GetAsyncKeyState(i)== -32767)
{
cout<<int (i)<<endl;
}
}
return 0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.