S
S
Stratimon2016-01-24 21:18:22
C++ / C#
Stratimon, 2016-01-24 21:18:22

How to get the color of a pixel in an inactive game window?

I use the graphics.h library
Actually my actions

HWND test = FindWindow("MSPaintApp","Безымянный - Pain");
HDC test2 = GetDC(test);
int pixel_color = GetPixel(test2, 520, 475 );
cout << hex << pixel_color << "\n";

I put this thing in a cycle and change the color in the paint, everything works fine.
But when I do the same with the game, problems begin, I set the coordinates, I start the program, it writes the color of the pixel, I start running, the colors change, but the program in the console gives out the same color. After I restart it, but it writes all the same value.
The task in the game after clicking may appear a window with the color of the pixel, let's say 0x1997DA at the coordinates x=100 y=100, and if it appears, do some action, for example cout << "cheers";
I also read that GetPixel is very slow but I don't think it's that much! checking for the color of a pixel in the coordinates is performed approximately once every 3 seconds.
And if there are problems in it, what are the alternatives?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antony, 2016-01-24
@RiseOfDeath

graphics.h - What is this, borland c++ builder 3 ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question