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 with program

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Mr.Panda
How do I cheat?
Reputation: 0

Joined: 06 Sep 2007
Posts: 3

PostPosted: Thu Sep 06, 2007 3:43 pm    Post subject: help with program Reply with quote

i was writing an auto clicker program, it compiles fine with no errors and clicks for the first couple of secs during execution, but after that my debugger says Unhandled exception at 0x00000002 in autoclick.exe: 0xC0000005: Access violation reading location 0x00000002. can anyone help me fix this problem?


[code]
#include "stdafx.h"
#include <windows.h>
#include <iostream>

typedef bool (_stdcall *API_TYPE)(DWORD, DWORD, DWORD, ULONG_PTR);
API_TYPE mouse_click;
HMODULE hUser32;

void clicker();
void prot();

int main()
{
prot();
std::cout << "user32 handle is " << hUser32 << "\n";
std::cout << "mouse_event is " << mouse_click << "\n";
clicker();
}

void clicker()
{
int i = 0;
POINT p;
GetCursorPos(&p);
while(i <= 1)
{
mouse_click(0x0002, p.x, p.y, 0);
mouse_click(0x0004, p.x, p.y, 0);
}
}
void prot()
{
hUser32 = GetModuleHandle(L"user32.dll");
mouse_click = (API_TYPE)GetProcAddress(hUser32, "mouse_event");
}
[/code]
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Sep 06, 2007 3:54 pm    Post subject: Reply with quote

if it sais "user32 handle is" + "Mouse_Event is" before it crashes then the problem is void clicker(), else the problem is in void prot()
_________________
Back to top
View user's profile Send private message
Programmer
Cheater
Reputation: 0

Joined: 02 Sep 2007
Posts: 48

PostPosted: Thu Sep 06, 2007 4:05 pm    Post subject: Reply with quote

Whats the point in while(i <= 1) if i is ALWAYS going to be 0?
_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Sep 06, 2007 4:17 pm    Post subject: Reply with quote

GetModuleHandle(L"user32.dll");

why is there an L there o.O?

_________________
Back to top
View user's profile Send private message
Mr.Panda
How do I cheat?
Reputation: 0

Joined: 06 Sep 2007
Posts: 3

PostPosted: Thu Sep 06, 2007 4:23 pm    Post subject: Reply with quote

the point of while(i<= 1) is to loop, and its pretty unncessary cause i could've used while(1), but thats how i write my loops

GetModuleHandle(L"user32.dll");

there is an L before "user32.dll" so the compiler wouldn't give me crap about converting a char to LPCWSTR
Back to top
View user's profile Send private message
Programmer
Cheater
Reputation: 0

Joined: 02 Sep 2007
Posts: 48

PostPosted: Thu Sep 06, 2007 4:29 pm    Post subject: Reply with quote

Mr.Panda wrote:
the point of while(i<= 1) is to loop, and its pretty unncessary cause i could've used while(1), but thats how i write my loops

GetModuleHandle(L"user32.dll");

there is an L before "user32.dll" so the compiler wouldn't give me crap about converting a char to LPCWSTR


1. It's an extra compare. Use for(;Wink

2. Project Settings -> Multi-Bye Character set

_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Sep 06, 2007 4:32 pm    Post subject: Reply with quote

i got it, you need to kick your compiler, right in the arse

Code:
//#include "stdafx.h"
#include <windows.h>
#include <iostream>

typedef bool (_stdcall *API_TYPE)(DWORD, DWORD, DWORD, ULONG_PTR);
API_TYPE mouse_click;
HMODULE hUser32;

void clicker();
void prot();

int main()
{int i = 0;
prot();
std::cout << "user32 handle is " << hUser32 << "\n";
std::cout << "mouse_event is " << mouse_click << "\n";
while(i==0)
{
clicker();
}
}

void clicker()
{

POINT p;
GetCursorPos(&p);
mouse_click(0x0002, p.x, p.y, 0);
mouse_click(0x0004, p.x, p.y, 0);

}
void prot()
{
hUser32 = GetModuleHandle("user32.dll");
mouse_click = (API_TYPE)GetProcAddress(hUser32, "mouse_event");
}


trust me it works, i just got stuck in a mad click frenzy :[

it didn't work because you only GetCursorPost(&p) 1 time, so when the mouse moves, it messes it up

add hotkeys

_________________
Back to top
View user's profile Send private message
Programmer
Cheater
Reputation: 0

Joined: 02 Sep 2007
Posts: 48

PostPosted: Thu Sep 06, 2007 4:44 pm    Post subject: Reply with quote

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

typedef bool (_stdcall *API_TYPE)(DWORD, DWORD, DWORD, ULONG_PTR);
API_TYPE mouse_click;
HMODULE hUser32;

void clicker();
void prot();
bool on = false;

int main()
{int i = 0;
prot();
std::cout << "user32 handle is " << hUser32 << "\n";
std::cout << "mouse_event is " << mouse_click << "\n";
for(;;)
{
clicker();
}
}

void clicker()
{
if(GetAsyncKeyState(VK_F1) && on == false)
{ on = true; } else {on = false;}

if(on)
{
POINT p;
GetCursorPos(&p);
mouse_click(0x0002, p.x, p.y, 0);
mouse_click(0x0004, p.x, p.y, 0);
}
}
}

void prot()
{
hUser32 = GetModuleHandle("user32.dll");
mouse_click = (API_TYPE)GetProcAddress(hUser32, "mouse_event");
}


Not tried it, but it should work.

_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Sep 06, 2007 4:46 pm    Post subject: Reply with quote

you just took my code snippet and put for(;Wink instead of while

notice the declaration of integer i even though you dont use it ;]

_________________
Back to top
View user's profile Send private message
Programmer
Cheater
Reputation: 0

Joined: 02 Sep 2007
Posts: 48

PostPosted: Thu Sep 06, 2007 6:05 pm    Post subject: Reply with quote

blankrider wrote:
you just took my code snippet and put for(;Wink instead of while

notice the declaration of integer i even though you dont use it ;]


Yeah, and added a hotkey like you said. What, you think i have time to re-write this piece of junk? Razz

_________________
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Thu Sep 06, 2007 6:24 pm    Post subject: Reply with quote

didn't see that, i prefer RegisterHotKey
_________________
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