getPixel() and dual monitors

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

getPixel() and dual monitors

#1 Post by vIndie » Fri Apr 06, 2012 4:25 pm

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.

Here is the code I used to test.

Code: Select all

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);

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: getPixel() and dual monitors

#2 Post by Administrator » Sat Apr 07, 2012 2:37 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests