 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
A_jj74 Cheater
Reputation: 0
Joined: 14 Nov 2009 Posts: 41
|
Posted: Tue Dec 01, 2009 3:08 am Post subject: |
|
|
| slovach wrote: | The blit will probably need a couple megabytes of memory.
blitting my entire screen jumped up the memory usage by pretty much exactly what I expected, around 5mb. Hardly a problem.
Here's a simple function for cleaning up when you're done. Don't start creating and destroying DC's mid loop as you'll only hurt performance.
| Code: | BOOL Cleanup(void)
{
if(SelectObject(hdcMem, hbmOld))
{
if(DeleteObject(hDib))
if(ReleaseDC(hwnd, hdc))
if(DeleteDC(hdcMem))
return TRUE;
}
return FALSE;
} |
You may have noticed the differences in what GetPixel returns vs the raw pixel data.
Example being, checking the color of the back button on my browser.
| Code: | xxRRGGBB
DIB, 0x000044c0
dec, 00 68 192
xxBBGGRR
GP, 0x00c04400
dec, 192 68 00 |
Confused yet?
One returns RGB while the other returns BGR
(endian-ness is another matter...)
So yes, this is likely what is wrong with your color checks / why you're getting strange discrepancies between the two.
If you want to put the raw pixel data in the same format that GetPixel returns, you can just do something like...
| Code: | void SwapCol(DWORD* ptr)
{
*ptr = (*ptr & 0x000000FF) << 16 | (*ptr & 0x0000FF00) | (*ptr & 0x00FF0000) >> 16;
} |
and use it like:
| Code: | COLORREF c = ReadPixel(30, 60);
SwapCol(&c);
... now do whatever |
|
I already thought it has something to do with the Colors, because it scans the Screen way faster than GetPixel() and it always clicked on weird colors.
I'll try that out.
EDIT: it is kinda confusing because i use:
| Code: | redValue = GetRValue(c);
greenValue = GetGValue(c);
blueValue = GetBValue(c); |
so the redValue should be the redvalue of the Pixel.
so the greenValue should be the greenvalue of the Pixel.
and the blueValue should be the bluevalue of the Pixel.
But it might be that GetRValue gets the bluevalue because its meant for GetPixel().
And here are those god damn Bonus Boxes.
Note: They are Rotating so it's rather Difficult to get the right color.
Last edited by A_jj74 on Sat Dec 05, 2009 2:53 am; edited 1 time in total |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Tue Dec 01, 2009 11:31 am Post subject: |
|
|
| Tvirusx1 wrote: | I already thought it has something to do with the Colors, because it scans the Screen way faster than GetPixel() and it always clicked on weird colors.
I'll try that out.
EDIT: it is kinda confusing because i use:
| Code: | redValue = GetRValue(c);
greenValue = GetGValue(c);
blueValue = GetBValue(c); |
so the redValue should be the redvalue of the Pixel.
so the greenValue should be the greenvalue of the Pixel.
and the blueValue should be the bluevalue of the Pixel.
But it might be that GetRValue gets the bluevalue because its meant for GetPixel(). |
yes, just use SwapCol to get it in the same format, then you can use the included macros no problem. Windows often uses BGR.
Also the RGB macro will probably simplify that somewhat. Example:
| Code: | COLORREF c = ReadPixel(32, 32);
SwapCol(&c);
if(c == RGB(255, 0, 0)) //red
//go hog wild, color matched |
You can also just use the numerical value straight up and ignore all that stuff.
| Code: | COLORREF c = ReadPixel(32, 32);
if(c == 0x00FF0000) //red |
Assuming they all play the same frame of animation at one point or another, it shouldn't be too hard to find a unqiue color out of it.
My first click on a square was 245r, 245g, 199b (or 0x00F5F5C7)
If the square is never obscured by another object, that probably sounds like a safe enough bet that the others will get display that at one point or another. It's almost a cream color, so that sounds unique enough to avoid false positives.
|
|
| Back to top |
|
 |
A_jj74 Cheater
Reputation: 0
Joined: 14 Nov 2009 Posts: 41
|
Posted: Wed Dec 02, 2009 2:28 am Post subject: |
|
|
| Quote: | | Assuming they all play the same frame of animation at one point or another, it shouldn't be too hard to find a unqiue color out of it. |
It's really difficult. It may not seem so but it is. I tried over 150 Colors and I'm still trying.
I even tried the Color you picked: "245r, 245g, 199b", no success.
My ship just always flies past them...
My Program has roughly 1-3 Seconds time to Find the Color and Click, because my Ship is moving. (depending on the ship speed, and I have the fastest ship)
Even If I stop my ship right next to a Bonus Box for 10-20 seconds it still doesn't find it.
I don't think I'll get anywhere with a single Color, I think the solution to this would be a "Color Tolerance" or something like that.
I assume you know what a Color Tolerance is so I wont explain 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
|
|