Hi I am trying to experiment with GetPixel() to see if I can get a color output. So far this is my code:
Code:
#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
COLORREF lcolor = 0;
int lx = 653, ly = 347;
HWND hwnd = FindWindow(0, L"Hearts");
HDC hdc = GetWindowDC(hwnd);
Sleep(5000);
lcolor=GetPixel(hdc,lx,ly);
int r = GetRValue ( lcolor );
int g = GetGValue ( lcolor );
int b = GetBValue ( lcolor );
cout << r << endl;
cout << g << endl;
cout << b << endl;
return 0;
}
As you can see I am trying to get different color values from the Hearts game included in Windows 7. However, whenever I run my program, I always get RGB values such as 255 255 255 for red, green, and blue respectively. With the coordinates x = 653, y = 347, certainly it would be very hard to miss the large mass of green in the background.
What am I doing wrong? Thank you for your time.
NOTE: The 5 seconds delay is to give me time to switch to the Hearts program in full screen.
IDE used is Visual Studio 2010. OS is Windows 7.