獲取本程序接收到的鍵盤消息

 1 #include <Windows.h>
 2 #include <iostream>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     while(true)
 8     {
 9         if(-32767 == GetAsyncKeyState(VK_SPACE))
10             cout<<" ";
11         else if(-32767 == GetAsyncKeyState('A'))
12             cout<<"A";
13         else if(-32767 == GetAsyncKeyState('B'))
14             cout<<"B";
15         else if(-32767 == GetAsyncKeyState('C'))
16             cout<<"C";
17         else if(-32767 == GetAsyncKeyState('D'))
18             cout<<"D";
19         else if(-32767 == GetAsyncKeyState('E'))
20             cout<<"E";
21     }
22     return 0;
23 }
相關文章
相關標籤/搜索