Odd issue with getPixel using 2 different pcs

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
Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Odd issue with getPixel using 2 different pcs

#1 Post by Exempt » Sat Aug 20, 2016 11:15 pm

I was trying to move over my MM scripts and things to a second pc I have and oddly enough the getPixel function doesn't work on the new pc. It's a windows 10 pc vs my old is still windows 7, is this a known issue or just me?

I'm pretty much just do this...

Code: Select all

local hwnd;
local winX, winY, wWidth, wHeight;

function macro.init()
	hwnd = window.find("Untitled");
	winX, winY, wWidth, wHeight = window.getClientRect(hwnd);
	printf("X %d, Y %d, W %d, H %d \n", winX, winY, wWidth, wHeight);
end

function macro.main(dt)
	return true;
end

function macro.event(e, data1, data2, data3)
	if(e == "keypressed" and data1 == key.VK_Y) then
		x, y = mouse.getPosition();
		x = x - winX;
		y = y - winY;
		printf("mouse_x: %d, mouse_y: %d \n", x, y);
		r,g,b = window.getPixel(hwnd, x, y);
		printf("RGB: %d, %d, %d\n", r, g, b);
	end
end

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#2 Post by Exempt » Sun Aug 21, 2016 10:14 am

I'm certain the cords are correct and the hwnd is also correct so it must be something with getPixel.

Edit: I also tried compatibility modes for win 7 with no luck.

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

Re: Odd issue with getPixel using 2 different pcs

#3 Post by Administrator » Sun Aug 21, 2016 11:46 am

What do you mean by "it doesn't work"? Does it give incorrect results? An error message? Could you provide a copy of a log file to see if maybe it is failing to set the debug mode or something? Do you have any sort of anti-virus or other software that could be interfering with the access of screen data?

I believe the way getPixel is working is by actually screenshotting the desktop and using that as the canvas to pull pixels from. This is so that it won't need to actually do anything that would be blocked by malware such as GameGuard, and any weirdness with the rendering engine. Of course this isn't fool-proof so might not work everywhere, so that could very well be the cause of the issue.

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#4 Post by Exempt » Sun Aug 21, 2016 1:25 pm

The output of the color is just always wrong. I will go look for some kind of log.

Nothing in the log files at all though I did notice something off just now... X 786, Y 52, W 643, H 482 is the outut from getClientRect but the window size is 800x600 I'd think the sizes are off by way to much.
At 1200x800 is gives X 569, Y 34, W 962, H 643 with getClientRect and X 566, Y 9, W 965, H 668 with getRect. I need to find a way to check my actual screen size

Edit: Using paint to get a window size the overall width is 1200 like it is set to, I wonder why getRect and getClientRect would be off in the size.

Edit: I used window.setRect to set the size and position which does make getClientRect return the correct numbers but sadly it doesn't fix the wrong color being returned

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

Re: Odd issue with getPixel using 2 different pcs

#5 Post by Administrator » Sun Aug 21, 2016 9:05 pm

I remember fixing some issues with those functions a long time ago, and I doubt that is the cause of this but just to make sure, which version are you using? Can you also specify if it is broken on both of your computers, or only on one or the other?

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#6 Post by Exempt » Sun Aug 21, 2016 9:42 pm

Only this new pc has the issue and I have the latest version that can be downloaded I believe 1.94 is the version.

My new pc is a hp laptop with windows 10 on it. I'm not sure if any of the hardware could be the cause.

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

Re: Odd issue with getPixel using 2 different pcs

#7 Post by Administrator » Sun Aug 21, 2016 11:57 pm

Is the window you're trying to read from fully visable (ie. on top of all other windows, or at least not covered by another)? Since it uses a screenshot, it will read from whatever is on the screen rather than what is rendered to the window. That is, if I remember how getPixel() works.

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#8 Post by Exempt » Mon Aug 22, 2016 6:37 am

Yes it is the focused window.

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

Re: Odd issue with getPixel using 2 different pcs

#9 Post by Administrator » Tue Aug 23, 2016 11:44 pm

Try dropping this executable in your folder, overwriting the original, then run it. It'll dump extra info to the log on a getPixel() call. Post your log here for review.
Attachments
micromacro.exe.only.zip
(322.18 KiB) Downloaded 381 times

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#10 Post by Exempt » Sat Aug 27, 2016 4:03 pm

I can't get that to run at all, it says missing dlls on fresh install of the latest stable client and when using it on the 1.94 it says missing sqllite3.dll. In the folder of 1.94 version I found a libsqllite3.dll which I renamed to just sqllite3.dll but then it get another error "The application was unable to start correctly (0xc000007b)"

Edit: Nvm, you're using the x86 version. I will test this out now.

2016-08-27 15:14:42 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:14:42 : Mapped local coordinates (387, 231) to screen coordinates (389, 256)
2016-08-27 15:14:42 : Obtained COLORREF 0x141619 - Unwound to: 25, 22, 20
2016-08-27 15:14:44 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:14:44 : Mapped local coordinates (116, 56) to screen coordinates (118, 82)
2016-08-27 15:14:44 : Obtained COLORREF 0xA3B84 - Unwound to: 132, 59, 10
2016-08-27 15:14:45 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:14:45 : Mapped local coordinates (118, 29) to screen coordinates (120, 54)
2016-08-27 15:14:45 : Obtained COLORREF 0x3D3939 - Unwound to: 57, 57, 61
2016-08-27 15:14:48 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:14:48 : Mapped local coordinates (3, 0) to screen coordinates (5, 26)
2016-08-27 15:14:48 : Obtained COLORREF 0xFFFFFF - Unwound to: 255, 255, 255
2016-08-27 15:14:54 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:14:54 : Mapped local coordinates (792, 569) to screen coordinates (794, 594)
2016-08-27 15:14:54 : Obtained COLORREF 0x606C75 - Unwound to: 117, 108, 96
2016-08-27 15:14:57 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:14:57 : Mapped local coordinates (392, 276) to screen coordinates (394, 302)
2016-08-27 15:14:57 : Obtained COLORREF 0x2A2929 - Unwound to: 41, 41, 42
2016-08-27 15:15:00 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:15:00 : Mapped local coordinates (795, 0) to screen coordinates (797, 26)
2016-08-27 15:15:00 : Obtained COLORREF 0xFFFFFF - Unwound to: 255, 255, 255
2016-08-27 15:15:06 : Grabbed desktop DeviceContext: 0xD8011385
2016-08-27 15:15:06 : Mapped local coordinates (3, 569) to screen coordinates (5, 594)
2016-08-27 15:15:06 : Obtained COLORREF 0x191B20 - Unwound to: 32, 27, 25
Using the same code as above with only 1 change I set the location and size of the window when I init

Code: Select all

window.setRect(hwnd, 0, 0, 800, 600);
EDIT:
This is a second one that I saved my output from...
mouse_x: 92, mouse_y: 108
RGB: 39, 38, 37
mouse_x: 8, mouse_y: 5
RGB: 255, 255, 255
mouse_x: 785, mouse_y: 562
RGB: 124, 123, 116
mouse_x: 36, mouse_y: 159
RGB: 47, 47, 47
mouse_x: 336, mouse_y: 92
RGB: 24, 21, 20
2016-08-27 15:44:02 : Grabbed desktop DeviceContext: 0x2C011346
2016-08-27 15:44:02 : Mapped local coordinates (92, 108) to screen coordinates (94, 134)
2016-08-27 15:44:02 : Obtained COLORREF 0x252627 - Unwound to: 39, 38, 37
2016-08-27 15:44:10 : Grabbed desktop DeviceContext: 0x5E010AF2
2016-08-27 15:44:10 : Mapped local coordinates (8, 5) to screen coordinates (10, 30)
2016-08-27 15:44:10 : Obtained COLORREF 0xFFFFFF - Unwound to: 255, 255, 255
2016-08-27 15:44:13 : Grabbed desktop DeviceContext: 0x5E010AF2
2016-08-27 15:44:13 : Mapped local coordinates (785, 562) to screen coordinates (787, 587)
2016-08-27 15:44:13 : Obtained COLORREF 0x747B7C - Unwound to: 124, 123, 116
2016-08-27 15:44:15 : Grabbed desktop DeviceContext: 0x5E010AF2
2016-08-27 15:44:15 : Mapped local coordinates (36, 159) to screen coordinates (38, 184)
2016-08-27 15:44:15 : Obtained COLORREF 0x2F2F2F - Unwound to: 47, 47, 47
2016-08-27 15:44:16 : Grabbed desktop DeviceContext: 0x5E010AF2
2016-08-27 15:44:16 : Mapped local coordinates (336, 92) to screen coordinates (338, 118)
2016-08-27 15:44:16 : Obtained COLORREF 0x141518 - Unwound to: 24, 21, 20

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#11 Post by Exempt » Sat Aug 27, 2016 8:01 pm

From that log file it acts like everything is right but even in paint using solid black ad white the colors do not come out right.

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

Re: Odd issue with getPixel using 2 different pcs

#12 Post by Administrator » Sun Aug 28, 2016 12:58 pm

I'm not able to duplicate the issue still.
Testing on Windows 10 pro x64, dual 1080p monitors.

This is the slightly modified script I'm testing with:

Code: Select all

local hwnd;
local winX, winY, wWidth, wHeight;

function macro.init()
	hwnd = window.find("Untitled");
	printf("Targeted %s\n", window.getTitle(hwnd));
	winX, winY, wWidth, wHeight = window.getClientRect(hwnd);
	printf("X %d, Y %d, W %d, H %d \n", winX, winY, wWidth, wHeight);
end

function macro.main(dt)
	return true;
end

function macro.event(e, data1, data2, data3)
	if(e == "keypressed" and data1 == key.VK_Y) then
		winX, winY, wWidth, wHeight = window.getClientRect(hwnd);
		x, y = mouse.getPosition();
		x = x - winX;
		y = y - winY;
		printf("mouse_x: %d, mouse_y: %d \n", x, y);
		r,g,b = window.getPixel(hwnd, x, y);
		printf("RGB: %d, %d, %d\n", r, g, b);
	end
end
I opened up MS Paint, set background to black and painted various color splotches. I start the script, place the mouse over the center of each color splotch and press Y, then I went to Edit colors and input the RGB values to ensure that it was the right color and shade; they were all correct.

I'm really at a loss for what could be causing your issues. If you test the same area, do you still get the same result every time or is it random? What happens if you move the window but test the same spot?

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#13 Post by Exempt » Sun Aug 28, 2016 1:01 pm

It does seem to be consistent when I stay in the same spot. I will just test it with your script to be sure but I have done an exact copy from my main pc to my new one and still no luck.

I just had an idea..(yes it hurt my head) This laptop has 2 graphics options on it, the integrated card and a NVidia card. I had the driver for the integrated card disabled because it was causing graphics issues in games as it was using the intel integrated graphics by default for some reason. Now sadly that seems to be the cause of this because for whatever reason micromacro is using some other resolution which is throwing everything off(My best guess). That is why I get windows sizes that are not correct unless I resize them but then I assume the window location is not correct after that because the strange resolution.

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

Re: Odd issue with getPixel using 2 different pcs

#14 Post by Administrator » Sun Aug 28, 2016 1:37 pm

I don't think it has to do with resolution, as that's not taken into any computation in MicroMacro at all; it's just making raw calls to the Windows API. It certainly could be related to issues with your video card, but that seems a bit odd to me. I mean, I've got an integrated card and 2 dedicated (Radeon 270x in Crossfire), and although I have various glitches due to the crappy drivers they put out, I'm not having any such issue like you describe.

Are you able to validate that the screen coordinates dumped in the log are correct? Easiest way to check this is probably just to take a screenshot with Print Screen, dump it into whatever image editor, and find the coordinate you were checking against.

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#15 Post by Exempt » Sun Aug 28, 2016 1:41 pm

It fixes the problem so it is related somehow I guess but now I need to sort out how to make it use the NVidia card. thanks

Edit: The cause must be because it's possible to run 2 apps using 2 different graphics options and best I can tell micromacro defaulted to w/e base driver windows 10 uses when no drivers is installed. I think after forcing everything to run on the NVidia card the problem is sorted.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: Odd issue with getPixel using 2 different pcs

#16 Post by beanybabe » Mon Aug 29, 2016 2:14 am

I seen some old nvidia cards do strange things in some zones they were cares older than the 300 series.

Exempt
Posts: 197
Joined: Wed Jan 20, 2010 9:55 am

Re: Odd issue with getPixel using 2 different pcs

#17 Post by Exempt » Tue Aug 30, 2016 5:13 pm

Sadly, this was mostly caused by my ignorance when it comes to new laptops. They have many more power options that can cause issues.

Jososyhet
Posts: 2
Joined: Sat Jun 08, 2019 10:55 pm

Odd issue with getPixel using 2 different pcs

#18 Post by Jososyhet » Mon Jun 10, 2019 9:09 pm

Thanks. That mod worked. Now I just have the same old issue again with the stove and fridge. Is it okay to comment on my told topic about it instead of making a new one?

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests