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 


Some Help!

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
GRB
Advanced Cheater
Reputation: 0

Joined: 17 Nov 2006
Posts: 53

PostPosted: Sun Mar 09, 2008 1:50 pm    Post subject: Some Help! Reply with quote

Can anyone help me here plz?

Code:
#include <windows.h>
#include <winuser.h>
#include <windef.h>

BOOL qQuit = FALSE;
HMODULE mModule;

void Thread()
{
   while ( !bWantQuit )
   {
      if (GetAsyncKeyState(VK_F1))
      {
      MessageBox (NULL, L"Working", NULL, MB_OK);
      }
      if (GetAsyncKeyState(VK_F2))
      {
         keybd_event(VK_RETURN, 0, 0, 0);
         keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
         ::Sleep(500);
         keybd_event(VK_NUMPAD1, 0, 0, 0);
         keybd_event(VK_NUMPAD1, 0, KEYEVENTF_KEYUP, 0);
         keybd_event(VK_NUMPAD2, 0, 0, 0);
         keybd_event(VK_NUMPAD2, 0, KEYEVENTF_KEYUP, 0);
         keybd_event(VK_RETURN, 0, 0, 0);
         keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
         qQuit = TRUE;
      }
   }
   FreeLibraryAndExitThread(mModule,0);
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                  )
{
   if (ul_reason_for_call == DLL_PROCESS_ATTACH)
   {
      DisableThreadLibraryCalls( hModule );
      thisModule = hModule;
      CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&Thread, (LPVOID)hModule, 0, 0);
   }
   return TRUE;
}


This is to inject in a game!

I already have injected it and it works, but only works one time, how can i make it works everytime i press the F1?

EDIT: BTW this is just for testing purposes!
Back to top
View user's profile Send private message Visit poster's website
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sun Mar 09, 2008 1:56 pm    Post subject: Re: Some Help! Reply with quote

GRB wrote:
Can anyone help me here plz?

Code:
#include <windows.h>
#include <winuser.h>
#include <windef.h>

BOOL qQuit = FALSE;
HMODULE mModule;

void Thread()
{
   while ( !bWantQuit )
   {
      if (GetAsyncKeyState(VK_F1))
      {
      MessageBox (NULL, L"Working", NULL, MB_OK);
      }
      if (GetAsyncKeyState(VK_F2))
      {
         keybd_event(VK_RETURN, 0, 0, 0);
         keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
         ::Sleep(500);
         keybd_event(VK_NUMPAD1, 0, 0, 0);
         keybd_event(VK_NUMPAD1, 0, KEYEVENTF_KEYUP, 0);
         keybd_event(VK_NUMPAD2, 0, 0, 0);
         keybd_event(VK_NUMPAD2, 0, KEYEVENTF_KEYUP, 0);
         keybd_event(VK_RETURN, 0, 0, 0);
         keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
         qQuit = TRUE;
      }
   }
   FreeLibraryAndExitThread(mModule,0);
}

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                  )
{
   if (ul_reason_for_call == DLL_PROCESS_ATTACH)
   {
      DisableThreadLibraryCalls( hModule );
      thisModule = hModule;
      CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&Thread, (LPVOID)hModule, 0, 0);
   }
   return TRUE;
}


This is to inject in a game!

I already have injected it and it works, but only works one time, how can i make it works everytime i press the F1?

EDIT: BTW this is just for testing purposes!


First off, change the DllEntry method:

Code:

   switch( ul_reason_for_call )
   {
       case DLL_PROCESS_ATTACH:
           DisableThreadLibraryCalls( hModule );
           thisModule = hModule;
           CreateThread( 0, 0, ( LPTHREAD_START_ROUTINE ) &Thread, ( LPVOID ) hModule, 0, 0 );
           return TRUE;

        case DLL_PROCESS_DETACH:
            bWantQuit = true;
            return TRUE;
   }


Then, in your method

Code:

//.....
keybd_event(VK_RETURN, 0, 0, 0);
         keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0);
}


(Basically, remove the bWantsQuit in the method, because that tells it to quit--the first part is simply good programming practice.)

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
GRB
Advanced Cheater
Reputation: 0

Joined: 17 Nov 2006
Posts: 53

PostPosted: Mon Mar 10, 2008 5:52 am    Post subject: Reply with quote

im just trying ti learn c++, tkz for ur help!
Back to top
View user's profile Send private message Visit poster's website
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Mon Mar 10, 2008 6:10 am    Post subject: Reply with quote

You declared qQuit but your loop is looping while bWantQuit is false, which isn't declared, and after you send "12" you change qQuit to true, just remove it if you don't want it to quit.

And you should use SendInput.
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