[HELP] Scan for a certain pixel

Posts 1–15 of 38 · Page 1 of 3
[HELP] Scan for a certain pixel
Is there a winapi function or some other call that will search a window's rectangle for a certain pixel that i code. I thought there was one called "scan pixel" but apparently it doesn't exist, so does anyone know what i can do?
GetPixel()

Scan every pixel 'till the color you want comes up, then do something.
If you want to scan a special area, get the resolution of the screen, or the HWND you are using and then get it's corner positions and add them to the screen resolution.
GetPixel Function (Windows)
And there's the MSDN for GetPixel()
~lilneo
alright, here is my simple code i am using, i am just not understanding how to scan the whole window:

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

using namespace std;
int main()
{
	POINT p;
	HWND hwnd = GetDesktopWindow();
	HDC hdc = GetDC(hwnd);
	
	while(true)
	{
		GetCursorPos(&p);
		COLORREF rgb = GetPixel(hdc, p.x, p.y);
		COLORREF hey = GetRValue(rgb);
		COLORREF hey2 = GetGValue(rgb);
		COLORREF hey3 = GetBValue(rgb);
		if(GetAsyncKeyState(VK_SHIFT)&1){cout<<hey<<" "<<hey2<<" "<< hey3<<"\n";}
		}
	}
Quote Originally Posted by 258456 View Post
i am just not understanding how to scan the whole window:

GetWindowRect
ClientToScreen
Quote Originally Posted by Hell_Demon View Post
GetWindowRect
ClientToScreen
um, ok i used those functions but nothing happened, can someone just point out what's wrong with the code? here it is:


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

using namespace std;
int main()
{
	POINT p;
	HWND hwnd = GetDesktopWindow();
	HDC hdc = GetDC(hwnd);
	RECT rect;
	while(true)
	{
		GetClientRect(hwnd, &rect);
		ClientToScreen(hwnd, &p);
		GetCursorPos(&p);
		COLORREF rgb = GetPixel(hdc, p.x, p.y);
		COLORREF hey = GetRValue(rgb);
		COLORREF hey2 = GetGValue(rgb);
		COLORREF hey3 = GetBValue(rgb);
		if(GetAsyncKeyState(VK_SHIFT)&1){cout<<hey<<" "<<hey2<<" "<< hey3<<"\n";}
		if(hey == 211 && hey2 == 215 && hey3 == 243){MessageBox(hwnd, TEXT("YOU DID IT") ,TEXT("FINALLY"), MB_OK);}
[php]
for(int i=0;i<1024;i++)
{
for(int j=0;i<768;j++)
{
COLORREF ret = GetPixel(blah,i,j);
if(colorfound)
{
blah blah do something
}
}
}
[/php]

Epic semi-psuedo is epic.
Quote Originally Posted by BuRnYoUrSoUl View Post
Get Pixel ()
already posted.
Are you sure the colors are correct?
yes, the problem isn't that the color isn't right, it only gives me the messagebox if my cursor is on the certain pixel, i want it to scan the whole window and if the pixel is present then give me the messagebox
Quote Originally Posted by 258456 View Post
yes, the problem isn't that the color isn't right, it only gives me the messagebox if my cursor is on the certain pixel, i want it to scan the whole window and if the pixel is present then give me the messagebox
K hold up, I'm actually going to open my IDE now.
thanks a bunch void
GetPixel() its good trust me
dude i obviously used get pixel, give me some useful advice instead of repeating the posts before u

any progress?
Posts 1–15 of 38 · Page 1 of 3

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us