Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[HELP]c++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
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.

PostPosted: Fri Dec 21, 2007 4:45 am    Post subject: [HELP]c++ Reply with quote

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(;Wink
{
(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
View user's profile Send private message MSN Messenger
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Fri Dec 21, 2007 6:36 am    Post subject: Reply with quote

GetAsyncKeyState().
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
thepettson
Expert Cheater
Reputation: 0

Joined: 28 May 2007
Posts: 212
Location: Trying helping ppl at cef.

PostPosted: Fri Dec 21, 2007 6:50 am    Post subject: Reply with quote

the_undead wrote:
GetAsyncKeyState().


ok, thx alot. Very Happy Very Happy

_________________






post count:
150 [X] 200 [X] 250 [ ] 300 [ ]
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Dec 21, 2007 10:15 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
zonemikel
Newbie cheater
Reputation: 0

Joined: 20 Dec 2007
Posts: 18

PostPosted: Fri Dec 21, 2007 4:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
Aikos
Cheater
Reputation: 0

Joined: 26 Nov 2007
Posts: 47

PostPosted: Fri Dec 21, 2007 8:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites