[Help]GetPixel()

Posts 1–7 of 7 · Page 1 of 1
[Help]GetPixel()
Here is my code:
Code:
#include <iostream>
#include <windows.h>
#include "Getasynckeystates.h"
int main()
{
	POINT a;
	while(true)
	{
		HWND hwnd = FindWindow(NULL, NULL);
		HDC hdc = GetDC(hwnd);
		if(GetAsyncKeyState(sh) &1){
		GetCursorPos(&a);
		GetPixel(hdc, a.x, a.y);
		
		Sleep(20);
		}
		
	}
}
My problem is that, idk how i would make it tell me the color. Like i would put cout<<blahblha, but idk what to do. Thanks for ur help.
This is kind of off the top of my head.

GetPixel returns COLORREF btw.

[php]
COLORREF color = GetPixel(...);
BYTE red = GetRValue( (DWORD)color );
cout << red << endl;
[/php]
thanks void,
Code:
#include <iostream>
#include <windows.h>
#include "Getasynckeystates.h"
int main()
{
	POINT a;
	while(true)
	{
		HWND hwnd = FindWindow(NULL, NULL);
		HDC hdc = GetDC(hwnd);
		if(GetAsyncKeyState(sh) &1){
		GetCursorPos(&a);
		COLORREF color = GetPixel(hdc, a.x, a.y);
		BYTE red = GetRValue(color);
		std::cout<<red<<"\n";
		Sleep(20);
		}
		
	}
}
here is my code, it's not sending the value to the console, i am pretty sure i did something wrong, thanks for your help, I really appreciate it.
btw why aren't you a junior coder anymore? you know that purple title below ur name. They should make you it again, you are one of the few people on this forum that help in every thread.
press F11 and go step by step through it and everytime you should check your vars...
/ .
Doofbla, the reason I posted here was because I couldn't figure out what was wrong, I tried everything I could I just wanted an answer. And Stephen, u didn't help whatsoever the only person that has actually helped was void. If anyone would like to help please post but if u will just spam don't because there is no point. Doofbla I will thank anyways because u were trying to help.
Quote Originally Posted by 258456 View Post
Doofbla, the reason I posted here was because I couldn't figure out what was wrong, I tried everything I could I just wanted an answer. And Stephen, u didn't help whatsoever the only person that has actually helped was void. If anyone would like to help please post but if u will just spam don't because there is no point. Doofbla I will thank anyways because u were trying to help.
"Not all devices support GetPixel. An application should call GetDeviceCaps to determine whether a specified device supports this function."
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us