#include <iostream>
#define _WIN32_WINNT 0x0500
#include <windows.h>
int main()
{
int process=0;
/*ShowWindow(GetConsoleWindow(),SW_HIDE); when my program will works, i hide the console*/
while(true)
{
if(process==0)
{
if(GetKeyState('B') & 0x8000)
{
std::cout<<"b has been press"<<std::endl;
process=1;
}
else
{
process=0;
continue;
}
}
if(process==1)
{
if(GetKeyState('C') & 0x8000)
{
std::cout<<"c has been press"<<std::endl;
process=2;
}
else
{
process=0;
continue;
}
}
if(process==2)
{
if(GetKeyState('Q') & 0x8000)
{
std::cout<<"Q has been press"<<std::endl;
process=3;
}
else
{
process=0;
continue;
}
}
if(process==3)
{
if(GetKeyState('W') & 0x8000)
{
std::cout<<"W has been press"<<std::endl;
process=4;
}
else
{
process=0;
continue;
}
}
if(process==4)
{
if(GetKeyState('L') & 0x8000)
{
MessageBox(NULL,"WORK","YES",MB_OK);
break;
}
}
}
ShowWindow(GetConsoleWindow(),SW_SHOW);
return 0;
}
The problem is that: if i press b my program output "b has been press" more or less fifty-three times, and after if i press c,nothing happen, but if i press still b the program output other fifty-three times "b has been press".
Sorry for my bad English
Is this for a toy/schoolwork or a serious application? Hiding it on the screen is one thing, protecting it from other attacks is more complex.
If not on a compiler with <cornholio>, you can probably delete and replace the character with * faster than it can be seen, but that would be tricky, console programs are usually slow at updating text. You might find an answer in the console graphics extensions as well, *curses* family?