 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
123qwe Newbie cheater
Reputation: 0
Joined: 26 Dec 2006 Posts: 21
|
Posted: Mon Jan 12, 2009 3:59 pm Post subject: Getpixel problems |
|
|
my program crashes after looping once. anyone know why? thanks
| Code: | POINT pts;
DWORD WINAPI autopot(LPVOID)
{
HWND MuWnds = FindWindow("MU", NULL);
GetCursorPos(&pts);
while(1)
{
HDC theHDC = GetDC(MuWnds);
Sleep(10);
COLORREF rgb = GetPixelX(theHDC, 277, 977);
if(rgb != 6511962)
{
TypeStr("q");
}
if(GetAsyncKeyState(VK_NUMPAD0) & 0x8000)
{
return 0;
}
Sleep(10);
}
} |
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Mon Jan 12, 2009 4:32 pm Post subject: |
|
|
| Code: |
POINT pts;
DWORD WINAPI autopot(LPVOID)
{
HWND MuWnds = FindWindow("MU", NULL);
GetCursorPos(&pts);
HDC theHDC = GetDC(MuWnds);
do
{
COLORREF rgb = GetPixelX(theHDC, 277, 977);
if(rgb != 6511962)
{
TypeStr("q");
}
}while(!GetAsyncKeyState(VK_NUMPAD0));
return 0;
}
|
|
|
| Back to top |
|
 |
FerrisBuellerYourMyHero Master Cheater
Reputation: 0
Joined: 14 Feb 2007 Posts: 401 Location: Inside your <kernel>
|
Posted: Mon Jan 12, 2009 4:54 pm Post subject: |
|
|
tell me that isn't how your code really looks and you just messed up at copying it. You need to have proper formatting for it to be readable. Also when you use proper formatting, tab spacing, etc... you wont forget to put brackets in certain places and things like that.
it should look like this:
| Code: |
POINT pts;
DWORD WINAPI autopot(LPVOID)
{
HWND MuWnds = FindWindow("MU", NULL);
GetCursorPos(&pts);
while(1)
{
HDC theHDC = GetDC(MuWnds);
Sleep(10);
COLORREF rgb = GetPixelX(theHDC, 277, 977);
if(rgb != 6511962)
{
TypeStr("q");
}
if(GetAsyncKeyState(VK_NUMPAD0) & 0x8000)
{
return 0;
}
Sleep(10);
}
}
|
Now that being said, first of all your repeatedly calling GetDC but never releasing it. That will cause problems for sure. Also for indefinite loops use for instead of while. Are you sure your get pixel bypass is proper? are you hookhopping it or directly doing a syscall? Also what are you doing with the cursor position? you don't do anything with it in this code. If you use windowed mode you'll want to use ScreenToClient on the cursor position coordinates so its still accurate even if you used windowed mode.You don't need to Get the DC of the window either you can just get the desktop DC, you'll get the same pixel colors...
Try this
| Code: |
POINT pts;
DWORD WINAPI autopot(LPVOID)
{
HWND MuWnds = FindWindow("MU", NULL);
//GetCursorPos(&pts);
for(;; Sleep(10))
{
HDC theHDC = GetDC(MuWnds);
Sleep(10);
COLORREF rgb = GetPixelX(theHDC, 277, 977);
ReleaseDC(MuWnds, theHDC); // <-- you need to release the DC after using it
if(rgb != 6511962)
{
TypeStr("q");
}
if(GetAsyncKeyState(VK_NUMPAD0) & 0x8000)
{
return 0;
}
}
}
|
But why are you hard coding the pixel coordinates? and your doing pixel potting by checking if the pixel colors do not equal a certain value? For the game I play that doesn't work since the pixels can change color just my moving around or attacking (the bars blink), and you have to instead look for grey...
_________________
You know, life moves pretty fast. If you don't stop and look around once in a while, You could miss it!
 |
|
| Back to top |
|
 |
|
|
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
|
|