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 


[C++]On/Off on one hotkey not work :o (Solved)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 5:05 am    Post subject: [C++]On/Off on one hotkey not work :o (Solved) Reply with quote

HAXORZ/0x0000 - dont look at this, my problem is to turn Hack On/Off on one hotkey so i added check if its on/off and bool.
no error when compiling but i can only turn hack ON...

Code:
      if(GetAsyncKeyState(VK_F4)) //Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus = 0;
         *(WORD*)HAXORZ = 0x0000;
      }
         else
      {
      
         HaxStatus = 1;
         *(WORD*)HAXORZ = 0x0000;
      }


Last edited by Wiw3K on Mon Dec 22, 2008 10:15 am; edited 1 time in total
Back to top
View user's profile Send private message
HolyBlah
Master Cheater
Reputation: 2

Joined: 24 Aug 2007
Posts: 446

PostPosted: Mon Dec 22, 2008 5:31 am    Post subject: Reply with quote

Change it to:
Code:
if(GetAsyncKeyState(VK_F4)) //Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus = 1;
         *(WORD*)HAXORZ = 0x0000;
      }
         else
      {
       
         HaxStatus = 0;
         *(WORD*)HAXORZ = 0x0000;
      }
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Dec 22, 2008 5:36 am    Post subject: Reply with quote

Code:
if(GetAsyncKeyState(VK_F4)) //Hax On/Off
{
    HaxStatus ^= 1;
    *(WORD*)HAXORZ = 0x0000;
}
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 5:37 am    Post subject: Reply with quote

HolyBlah wrote:
Change it to:
Code:
if(GetAsyncKeyState(VK_F4)) //Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus = 1;
         *(WORD*)HAXORZ = 0x0000;
      }
         else
      {
       
         HaxStatus = 0;
         *(WORD*)HAXORZ = 0x0000;
      }

Still i can turn it only On... Shocked


---edit---
Jani wrote:
Code:
if(GetAsyncKeyState(VK_F4)) //Hax On/Off
{
    HaxStatus ^= 1;
    *(WORD*)HAXORZ = 0x0000;
}

no difference.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Dec 22, 2008 5:44 am    Post subject: Reply with quote

Code:
#include <windows.h>
#include <stdio.h>

DWORD HaxStatus = 0;

void x()
{
   if(GetAsyncKeyState(VK_F4)) //Hax On/Off
   {
      HaxStatus ^= 1;
      //*(WORD*)HAXORZ = 0x0000;
   }
}

int main(int argc, char *argv[])
{
   for(;;) {
      printf("%d", HaxStatus);
      x();
      Sleep(100);
   }

   return 0;
}
Works fine, so your problem is elsewhere:
Code:
test.exe
00000000000011111111111000011001001001001001001001101111111111111


EDIT: make sure that all your threads are running, since you're probably using an another thread to check the key statuses.


Last edited by Jani on Mon Dec 22, 2008 5:53 am; edited 1 time in total
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 5:53 am    Post subject: Reply with quote

Jani wrote:
Code:
#include <windows.h>
#include <stdio.h>

DWORD HaxStatus = 0;

void x()
{
   if(GetAsyncKeyState(VK_F4)) //Hax On/Off
   {
      HaxStatus ^= 1;
      //*(WORD*)HAXORZ = 0x0000;
   }
}

int main(int argc, char *argv[])
{
   for(;;) {
      printf("%d", HaxStatus);
      x();
      Sleep(100);
   }

   return 0;
}
Works fine, so your problem is elsewhere:
Code:
test.exe
00000000000011111111111000011001001001001001001001101111111111111

i am using Visual C++ 2008 and i am making DLL...

i had bool HaxStatus = 0; maybe this Confused

ill edit this post if it will work.

---edit---
still only can turn ON hack -.-
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Dec 22, 2008 5:57 am    Post subject: Reply with quote

Post your code.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 6:00 am    Post subject: Reply with quote

Jani wrote:
Post your code.

Code:
#include "stdafx.h"
#include "windows.h"
#define JMP(frm, to) (int)(((int)to - (int)frm) - 5);

DWORD HaxStatus = 0;

// Addresses
DWORD HaxAddy = 0x00000000;

bool JDLL(void) // Main code
   {
   MessageBoxA(0,"Welcome in TEH TRAINZORZ.\n     Press F1 In Game to View TEH TRAINZORZ.", "1337Trainzorz", 0);

   for(;;) // Main loop
   {
         // Add hotkey checks here

      if(GetAsyncKeyState(VK_F1)) //F1 = Help
      {
      MessageBoxA(0, "BLEBLEBLE TRAINZORZ.", "1337TRAINZORZ", 0);

         Sleep(200); // So the user doesn't press the key twice
      }
   
      if(GetAsyncKeyState(VK_F4)) //F4 = Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus ^= 1;
         *(WORD*)HaxAddy = 0x0000;
      }
         else
      {
      
         HaxStatus ^= 0;
         *(WORD*)HaxAddy = 0x0000;
      }
   return true;
      }
   }
}
BOOL APIENTRY DllMain(HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
{
   if (ul_reason_for_call == DLL_PROCESS_ATTACH)
   {
      CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&JDLL, 0, 0, 0); // Main thread
   }
   return true;
}
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Mon Dec 22, 2008 6:01 am    Post subject: Re: [C++]On/Off on one hotkey not work :o Reply with quote

Wiw3K wrote:
HAXORZ/0x0000 - dont look at this, my problem is to turn Hack On/Off on one hotkey so i added check if its on/off and bool.
no error when compiling but i can only turn hack ON...

Code:
      if(GetAsyncKeyState(VK_F4)) //Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus = 0;
         *(WORD*)HAXORZ = 0x0000;
      }
         else
      {
      
         HaxStatus = 1;
         *(WORD*)HAXORZ = 0x0000;
      }


Code:
bool On = false;     //Global
if (GetAsyncKeyState(VK_F4))
{
     On = !On;
     HackStatus ^= 1;
     *(WORD*)HAXORZ = 0x0000;
}

_________________
What dosen't kill you, usually does the second time.


Last edited by Heartless on Mon Dec 22, 2008 6:05 am; edited 1 time in total
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Dec 22, 2008 6:02 am    Post subject: Reply with quote

Code:
      if(GetAsyncKeyState(VK_F4)) //F4 = Hax On/Off
      {
         HaxStatus ^= 1;
         if (!HaxStatus)
               *(WORD*)HaxAddy = 0x0000;
         else
               *(WORD*)HaxAddy = 0x0000;
      }


Don't use operators you don't know :P Learn the first and then use 'em. So, do Google how xor works.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 6:04 am    Post subject: Re: [C++]On/Off on one hotkey not work :o Reply with quote

HornyAZNBoy wrote:
Code:
if (GetAsyncKeyState(VK_F4))
{
     HaxStatus = !HaxStatus;
     *(WORD*)HAXORZ = 0x0000;
}

how about turn it off? it should looks like that ?

Code:
      if(GetAsyncKeyState(VK_F4)) //F4 = Hax On/Off
      {
         HaxStatus ^= 1;
         *(WORD*)HaxAddy = 0x0000;
      }
         else
      {
      
         *(WORD*)HaxAddy = 0x0000;
      }
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Dec 22, 2008 6:08 am    Post subject: Re: [C++]On/Off on one hotkey not work :o Reply with quote

Wiw3K wrote:
how about turn it off? it should looks like that ?
HornyAZNBoy's idea is totally the same as mine, different way of implementing. The point is that the var is always changed when you execute that piece of code.
Back to top
View user's profile Send private message
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 7:26 am    Post subject: Re: [C++]On/Off on one hotkey not work :o Reply with quote

Jani wrote:
Wiw3K wrote:
how about turn it off? it should looks like that ?
HornyAZNBoy's idea is totally the same as mine, different way of implementing. The point is that the var is always changed when you execute that piece of code.

none of replies guys work Shocked

i know how it works -.-

After you click ex. F4 <-hack then the HaxStatus checks if its 1 or 0, if 0 then ON, if 1 then OFF. but doesnt work Sad
Back to top
View user's profile Send private message
Zerith
Master Cheater
Reputation: 1

Joined: 07 Oct 2007
Posts: 468

PostPosted: Mon Dec 22, 2008 7:39 am    Post subject: Re: [C++]On/Off on one hotkey not work :o Reply with quote

Wiw3K wrote:
Jani wrote:
Wiw3K wrote:
how about turn it off? it should looks like that ?
HornyAZNBoy's idea is totally the same as mine, different way of implementing. The point is that the var is always changed when you execute that piece of code.

none of replies guys work Shocked

i know how it works -.-

After you click ex. F4 <-hack then the HaxStatus checks if its 1 or 0, if 0 then ON, if 1 then OFF. but doesnt work Sad


in the else, you are writing the original bytes, right?

In case you do, try to debug your program, and figure out the problem.
Back to top
View user's profile Send private message MSN Messenger
Wiw3K
Grandmaster Cheater
Reputation: 0

Joined: 09 Jul 2006
Posts: 762
Location: Poland.

PostPosted: Mon Dec 22, 2008 7:42 am    Post subject: Reply with quote

yes take a look,

Code:
      if(GetAsyncKeyState(VK_F4)) //Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus = 0;
         *(WORD*)HAXORZ = 0x0000; //here i have modified one.
      }
         else
      {
     
         HaxStatus = 1;
         *(WORD*)HAXORZ = 0x0000; //Here Oryginal Bytes.
      }


i can check if this works adding MessageBoxes.

Code:
      if(GetAsyncKeyState(VK_F4)) //Hax On/Off
      {
         if (!HaxStatus)
      {
         HaxStatus = 0;
         *(WORD*)HAXORZ = 0x0000; //here i have modified one.
         MessageBoxA(0, "Hax On", "Hax", 0);
      }
         else
      {
     
         HaxStatus = 1;
         *(WORD*)HAXORZ = 0x0000; //Here Oryginal Bytes.
         MessageBoxA(0, "Hax Off", "Hax", 0);
      }

Wink


---edit---
this is dll how i can debug? xd
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
Goto page 1, 2  Next
Page 1 of 2

 
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