Jump to content
Sign in to follow this  
cag8f

Colors not matching: au3info vs. pixelgetcolor()

Recommended Posts

cag8f

I'm using the Autoit Windows Information Tool to determine the pixel coordinate ($X, $Y) and color hex value (lime green, 0x00FF00). But when I then run a simple Autoit script to confirm this:

hex(PixelGetColor($X, $Y)

I am met with a different color hex value (0000DD00).  Shouldn't the 2 hex values match?  If so, am I doing something wrong?

I found this old post describing a similar issue.  

'?do=embed' frameborder='0' data-embedContent>>

I tried to follow the recommendations but encountered a problem.  I made sure that the Coord Mode in AutoItInfo was set to 'screen,' but I couldn't find where to set Opt("PixelCoordMode", ?). It doesn't appear to be in the User Options or Global Options files.

Thanks in advance.

Share this post


Link to post
Share on other sites
JLogan3o13

Just out of curiosity, what is the end result once you get the hex value (e.g. what are you trying to manipulate)? There is likely (almost always) and easier way to accomplish what you're after than having to resort to matchin pixel colors.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
cag8f

The colors, and use of Autoit to determine those colors, are the end result.  I'm teaching an introductory programming class to high school students and wanted to do this as a lesson.  But this is behavior I can't explain, so I'd like to understand what is happening before the lesson.

Share this post


Link to post
Share on other sites
cag8f

I tried all 3 and get the same results with each.

Share this post


Link to post
Share on other sites
cag8f

No it does not.

edit:  should it have?

Edited by cag8f

Share this post


Link to post
Share on other sites
Malkey

...

I found this old post describing a similar issue.  

 

'?do=embed' frameborder='0' data-embedContent>>

 

I tried to follow the recommendations but encountered a problem.  I made sure that the Coord Mode in AutoItInfo was set to 'screen,' but I couldn't find where to set Opt("PixelCoordMode", ?). It doesn't appear to be in the User Options or Global Options files.

 

Thanks in advance.

To be put near the top of your script, below any include files.

Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client

Share this post


Link to post
Share on other sites
cag8f

@Malkey, thank you.  I added that code though, but with the same results.  

@JohnOne.  Thanks for your help.

>> My guess is there is more to your code and it's calculation of x and y, and that is where your problem lies.

For testing purposes, I've reduced my code down to one line:

ConsoleWrite(hex(PixelGetColor($X,$Y), 6) & @CR)

Anyone else have any ideas why this is happening?

Share this post


Link to post
Share on other sites
BrewManNH

I can't duplicate your issue, I tested with a pixel on the desktop background, and one inside the browser window. PixelGetColor was returning the same value as the info tool.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
cag8f

OK thanks for that info.  The difference in colors is very small:  00FF00, 00DD00.  So perhaps:

1. AU3info does uses a slightly different algorithm than pixelgetcolor() when calculating colors.  Highly unlikely, and maybe not even possible.

or 

2.  Since the colors are shades of themselves (lime green), they could be neighboring pixels.  So perhaps the coordinate systems between my AU3info and pixelgetcolor() are slightly off.  I will try to troubleshoot that more, perhaps by checking the coordinates/colors of the corner pixels.  I'll post back here if anyone's interested.  

Share this post


Link to post
Share on other sites
Malkey

Using this example,  I get the same mouse position and color on the tool tip as is on AU3info.

HotKeySet("{ESC}", "Terminate")
Local $aMPos

While 1
    $aMPos = MouseGetPos()
    ToolTip($aMPos[0] & ", " & $aMPos[1] & @LF & "0x" & Hex(PixelGetColor($aMPos[0], $aMPos[1]), 6))
    Sleep(10)
WEnd


Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Edit:Added Sleep.

Note: When the screen changes color without the mouse moving, I found the tool tip changes but the Au3Info color does not change until the mouse is moved.

Edited by Malkey

Share this post


Link to post
Share on other sites
cag8f

OK resolved for now.  User error I guess.  I had set 

Opt("PixelCoordMode", 0)

Instead of 

Opt("PixelCoordMode", 1)

Making that change gives me consistent colors.  Thanks for everyone's help!

Share this post


Link to post
Share on other sites
Nitrolord
On 8/11/2014 at 11:54 AM, cag8f said:

I'm using the Autoit Windows Information Tool to determine the pixel coordinate ($X, $Y) and color hex value (lime green, 0x00FF00). But when I then run a simple Autoit script to confirm this:

hex(PixelGetColor($X, $Y)

I am met with a different color hex value (0000DD00).  Shouldn't the 2 hex values match?  If so, am I doing something wrong?

I found this old post describing a similar issue.  

'?do=embed' frameborder='0' data-embedContent>>

I tried to follow the recommendations but encountered a problem.  I made sure that the Coord Mode in AutoItInfo was set to 'screen,' but I couldn't find where to set Opt("PixelCoordMode", ?). It doesn't appear to be in the User Options or Global Options files.

Thanks in advance.

I know this post is old but if your still wondering and for others who are still looking for the solution Check out my post.

 

Edited by Nitrolord

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×