2017-05-01 141 views
0

經過大量測試後,我無法記錄在C程序中是否使用GetAsyncKeyState按下Alt鍵。 當我試試這個:檢查ALT鍵是否被按下

if (GetAsyncKeyState(VK_SHIFT)) 
    // do something 

它可以正常工作,但是當我嘗試這個

if (GetAsyncKeyState(VK_MENU)) 
    // do something 

它不工作。
所以我的問題是「我如何記錄ALT?」。

在此先感謝

回答

2

我用下面的代碼,以找出完全符合GetAsyncKeyState任何鍵值,我認爲這是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; 
} 
+0

感謝您的回答 –

+0

歡迎您@FedericoLolli :) – Roy

相關問題