Reputation: 23
I had seen many people ask about this question before but it seem not really answer my question and i afraid to ask in other people question. I try to get Pixel color at (100,100) of the window. At this moment i can get it by using pixelsearch autoit but it not working when there is another window on top of it. So i just wonder is there anyway to make it work
au3.Sleep(1000);
SetForegroundWindow(hwndMain);
au3.PixelSearch(127, 232, 127, 232, 0x030100);
if (au3.error != 1)
{
SendMessage(hwndMain, WM_LBUTTONDOWN, new IntPtr(MK_LBUTTON), CreateLParam(127, 232));
SendMessage(hwndMain, WM_LBUTTONUP, new IntPtr(MK_LBUTTON), CreateLParam(127, 232));
au3.Sleep(1000);
//i++;
}
Upvotes: 0
Views: 220
Reputation: 28499
You know Schrödinger's Cat?
The point here is that the pixel has no definitive colour while that part of the window is not visible. In Windows, the contents of controls are drawn on request from the Operating System. When the operating system knows that a part of a window is not visible, it will not ask the window to draw that region.
You can use the PrintWindow() Windows API function to ask the Window to draw itself onto a device context (for example a Bitmap). You can then check the pixel in that Bitmap.
How to embed and use the PrintWindow() function see http://www.pinvoke.net/default.aspx/user32.printwindow
Upvotes: 1