| View previous topic :: View next topic |
| Author |
Message |
thepettson Expert Cheater
Reputation: 0
Joined: 28 May 2007 Posts: 212 Location: Trying helping ppl at cef.
|
Posted: Fri Dec 21, 2007 4:45 am Post subject: [HELP]c++ |
|
|
i'm trying to make a bot in c++. but i have stucked and need some help.
i need a code that is a endless loop but when u press that special key (like F10 or something) it will stop.
for(;
{
(the code)
(F10 pressed, the loop stop)
}
i hope u get what i mean..
_________________
post count:
150 [X] 200 [X] 250 [ ] 300 [ ] |
|
| Back to top |
|
 |
the_undead Expert Cheater
Reputation: 1
Joined: 12 Nov 2006 Posts: 235 Location: Johannesburg, South Africa
|
Posted: Fri Dec 21, 2007 6:36 am Post subject: |
|
|
GetAsyncKeyState().
_________________
|
|
| Back to top |
|
 |
thepettson Expert Cheater
Reputation: 0
Joined: 28 May 2007 Posts: 212 Location: Trying helping ppl at cef.
|
Posted: Fri Dec 21, 2007 6:50 am Post subject: |
|
|
| the_undead wrote: | | GetAsyncKeyState(). |
ok, thx alot.
_________________
post count:
150 [X] 200 [X] 250 [ ] 300 [ ] |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Dec 21, 2007 10:15 am Post subject: |
|
|
If you are doing a loop to check for a keypress I suggest you create a thread to monitor inside. Once you are inside the threads routine you can do:
| Code: | while( 1 )
{
if( GetAsyncKeyState( keyhere )&1 )
{
// Keypress code here.
}
} |
Mind you I would make the 1 in the while( ) a boolean that is monitored and set by your program when you are asking it to close, this way the thread can clean up properly. Meaning something like:
| Code: | while( !bIsAskingClose )
{
// ... code here
} |
Then having bIsAskingClose in your WM_CLOSE/WM_DESTROY event, or after the message pump in your program. If you are injecting a dll to do all this, set the boolean to true when DLL_PROCESS_DETACH is called.
_________________
- Retired. |
|
| Back to top |
|
 |
zonemikel Newbie cheater
Reputation: 0
Joined: 20 Dec 2007 Posts: 18
|
Posted: Fri Dec 21, 2007 4:16 pm Post subject: |
|
|
wow i make bots too here is some actual code that does just what you want, it is a menu system up/down cycles the choice variable then right arrow key executes it
| Code: | while(1)
{
Sleep(10); // so it dont lag !
if(GetAsyncKeyState(VK_UP) == -32767)
{
if(pBaseAddr != *(int *) 0x1AA3DCC)// if player is not current
{Hack.UpdatePlayer();} // get current player stuff
Choice++;
}
if(GetAsyncKeyState(VK_DOWN) == -32767)
{
Choice--;
}
if(GetAsyncKeyState(VK_RIGHT) == -32767)
{
switch(Choice)
{
case 0:
Hack.SBTravOut("SBTools2 Ready",
"- www.zonemikel.com -",
"UP/Down Cycles menu, Right Arrow Start, F12 Stop/MainMenu",
// some more code here
|
If you want to totally exit just put a
if(GetAsyncKeyState(somekey) == -32767)
{break;}
that should break the while loop if they hold it down and its in the outermost part.
|
|
| Back to top |
|
 |
Aikos Cheater
Reputation: 0
Joined: 26 Nov 2007 Posts: 47
|
Posted: Fri Dec 21, 2007 8:24 pm Post subject: |
|
|
| I did an autoclicker a while ago and I used a separate thread to handle the clicking, plus a hotkey to decide whether to resume or suspend the thread to control the clicking.
|
|
| Back to top |
|
 |
|