It doesn't appear that getPixel works correctly on the secondary monitor in dual monitor setup, it returns 255,255,255 regardless of the actual color of the pixel.
function main()
while(1) do
hwnd = foregroundWindow();
if (hwnd ~= 0) then
hdc = openDC(hwnd);
if (hdc) then
x,y = mouseGetPos();
-- printf("mouse_x: %d, mouse_y: %d", x, y);
r,g,b = getPixel(hdc, x, y);
printf("(%d, %d) RGB: %d, %d, %d\n", x,y, r, g, b);
closeDC(hdc);
end
end
stopPE();
end
end
startMacro(main);
Well, first problem is that getPixel expects client coordinates, not screen coordinates. That means that 0,0 is the top-left of the window, not the top-left of your screen. So, if you had dual monitors running 1920x1080 resolution and you had your mouse positioned at, say, 2000x20 (near the top-left corner of your second screen), that would be beyond the client area of the window, and hence be an invalid position to read pixel information from.