0
已解决
李宜和
高级启示者
高级启示者
#include <bits/stdc++.h>
#include<windows.h>
#include<iomanip>
#include<stdio.h>
#include<cstdlib>
#include<ctime>
using namespace std;
int main(){
srand(time(0));
CONSOLE_CURSOR_INFO info = { 1, 0 };
HANDLE hand = GetStdHandle( STD_OUTPUT_HANDLE );
COORD coord={ 0, 0 };
POINT pt={ 0, 0 };
SetConsoleCursorInfo( hand, &info );
string a="点击鼠标左键。",b="按Tab键。",d="按End键",e="按Page Up键",f="按Page Down键",g="按Left键",j="按Right键",k="按Ctrl键",l="按A";
int m,cnt=0;
while(1){
while(1){
m=rand()%9+1;
if(m==1){
cout<<a<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_LBUTTON)&0x01){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==2){
cout<<b<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_TAB)&0x09){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==3){
cout<<d<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_END)&0x23){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==4){
cout<<e<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_PRIOR)&0x21){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==5){
cout<<f<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_NEXT)&0x21){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==6){
cout<<g<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_LEFT)&0x25){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==7){
cout<<j<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_RIGHT)&0x27){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
if(m==8){
cout<<k<<endl;
Sleep(1500);
if(GetAsyncKeyState(VK_CONTROL)&0x11){
break;
}else{
cout<<"失败" ;
cnt=1;
break;
}
}
}
if(cnt==1){
break;
}
}
return 0;
}
回车键删了!!!!!!!!!!!
增加了一个键
话说有没有大佬告诉我:
怎么判断按下字母键