| View previous topic :: View next topic |
| Author |
Message |
Mr.Panda How do I cheat?
Reputation: 0
Joined: 06 Sep 2007 Posts: 3
|
Posted: Thu Sep 06, 2007 3:43 pm Post subject: help with program |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Sep 06, 2007 3:54 pm Post subject: |
|
|
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 |
|
 |
Programmer Cheater
Reputation: 0
Joined: 02 Sep 2007 Posts: 48
|
Posted: Thu Sep 06, 2007 4:05 pm Post subject: |
|
|
Whats the point in while(i <= 1) if i is ALWAYS going to be 0?
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Sep 06, 2007 4:17 pm Post subject: |
|
|
GetModuleHandle(L"user32.dll");
why is there an L there o.O?
_________________
|
|
| Back to top |
|
 |
Mr.Panda How do I cheat?
Reputation: 0
Joined: 06 Sep 2007 Posts: 3
|
Posted: Thu Sep 06, 2007 4:23 pm Post subject: |
|
|
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 |
|
 |
Programmer Cheater
Reputation: 0
Joined: 02 Sep 2007 Posts: 48
|
Posted: Thu Sep 06, 2007 4:29 pm Post subject: |
|
|
| 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(;
2. Project Settings -> Multi-Bye Character set
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Sep 06, 2007 4:32 pm Post subject: |
|
|
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 |
|
 |
Programmer Cheater
Reputation: 0
Joined: 02 Sep 2007 Posts: 48
|
Posted: Thu Sep 06, 2007 4:44 pm Post subject: |
|
|
| 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 |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Sep 06, 2007 4:46 pm Post subject: |
|
|
you just took my code snippet and put for(; instead of while
notice the declaration of integer i even though you dont use it ;]
_________________
|
|
| Back to top |
|
 |
Programmer Cheater
Reputation: 0
Joined: 02 Sep 2007 Posts: 48
|
Posted: Thu Sep 06, 2007 6:05 pm Post subject: |
|
|
| blankrider wrote: | you just took my code snippet and put for(; 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?
_________________
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Sep 06, 2007 6:24 pm Post subject: |
|
|
didn't see that, i prefer RegisterHotKey
_________________
|
|
| Back to top |
|
 |
|