问题标题: 成也回车,败也回车————狂按鼠标3.0!!!

0
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键。",c="按回车键。",d="按End键",e="按Page Up键",f="按Page Down键",g="按Left键",j="按Right键";
    int m,cnt=0;
    while(1){
        while(1){
            m=rand()%8+1;
            if(m==1){
                cout<<a<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_LBUTTON)&0x01){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            }   
            if(m==2){
                cout<<b<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_TAB)&0x09){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            }
            if(m==3){
                cout<<c<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_RETURN)&0x8000){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            }
            if(m==4){
                cout<<d<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_END)&0x23){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            } 
            if(m==5){
                cout<<e<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_PRIOR)&0x21){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            } 
            if(m==6){
                cout<<f<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_NEXT)&0x21){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            }
            if(m==7){
                cout<<g<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_LEFT)&0x25){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            }
            if(m==8){
                cout<<j<<endl;
                Sleep(2000);
                if(GetAsyncKeyState(VK_RIGHT)&0x27){
                    break;
                }else{
                    cout<<"失败" ;
                    cnt=1;
                    break;
                } 
            }
        }
        if(cnt==1){
            break;
        }   
    }
    return 0;
}

 


0
0
朱小川
朱小川
缔造者
缔造者

为什么失败就代码不执行了,而且能不能再多加一些按键

我要回答