Jump to content
Sign in to follow this  
Esam

PixelGetColor Problem

Recommended Posts

Esam

I'm having a problem with PixelGetColor in general. It NEVER seems to match what I get when using the AutoIt Window Info application. I created a little test program to try and show that they do not match. I have included a small section of my code where the problem occurs as well as a screenshot of the difference between the Window Info application and what PixelGetColor returns. I move the mouse there first just to prove to myself that I am looking at the correct coordinates before grabbing the color.

Unfortunately, the mouse pointer did not show up when I took the screenshot but it is at a known point in the green section of the selected radio button.

Opt("MouseCoordMode", 0)

MouseMove(39, 138, 100)

$coord = MouseGetPos()

msgBox(0, "Color Test", PixelGetColor($coord[0], $coord[1]))

sleep (5000)

Thanks!

Eric

Edited by Esam

Share this post


Link to post
Share on other sites
seandisanti

I'm having a problem with PixelGetColor in general. It NEVER seems to match what I get when using the AutoIt Window Info application. I created a little test program to try and show that they do not match. I have included a small section of my code where the problem occurs as well as a screenshot of the difference between the Window Info application and what PixelGetColor returns. I move the mouse there first just to prove to myself that I am looking at the correct coordinates before grabbing the color.

Unfortunately, the mouse pointer did not show up when I took the screenshot but it is at a known point in the green section of the selected radio button.

Opt("MouseCoordMode", 0)

MouseMove(39, 138, 100)

$coord = MouseGetPos()

msgBox(0, "Color Test", PixelGetColor($coord[0], $coord[1]))

sleep (5000)

Thanks!

Eric

try Opt("MouseCoordMode", 2) and see if that works for you

Share this post


Link to post
Share on other sites
Josbe

Only a suggestion for consistency in your verification, use ControlCommand(). An example:

$sTitle = "Internet Protocol (TCP/IP)"
$bVal = ControlCommand( $sTitle, '', "Button2", "IsChecked", "")
If $bVal Then
    MsgBox(0, "", "Is selected!")
Else
    MsgBox(0, "", "Isn't selected")
EndIf
Exit

Share this post


Link to post
Share on other sites
seandisanti

try Opt("MouseCoordMode", 2) and see if that works for you

and actually, if you're setting network settings, you may be able to save yourself some trouble by using netsh to set your network properties. you can set to DHCP mode with 1 line of code, or you can set a static ip and specify 2 dns servers with a total of 3 lines. I have all of the code for that on my laptop at home, because i made a little script to toggle it for my home network, or random unsecure network. If you google netsh usage, you should find a few sites that explain it in pretty good detail

Share this post


Link to post
Share on other sites
Esam

try Opt("MouseCoordMode", 2) and see if that works for you

Unfortunately this did not work for me and made my pointer miss where I was attempting to move it as well.

Edited by Esam

Share this post


Link to post
Share on other sites
Esam

I did not know you could do this... Thank you this looks preferable. HOWEVER, I still would like to know why my above example does not work as it should.

Only a suggestion for consistency in your verification, use ControlCommand(). An example:

$sTitle = "Internet Protocol (TCP/IP)"
$bVal = ControlCommand( $sTitle, '', "Button2", "IsChecked", "")
If $bVal Then
    MsgBox(0, "", "Is selected!")
Else
    MsgBox(0, "", "Isn't selected")
EndIf
Exit
Edited by Esam

Share this post


Link to post
Share on other sites
seandisanti

I did not know you could do this... Thank you this looks preferable. HOWEVER, I still would like to know why my above example does not work as it should.

you mean as you expect it to...

anyway, you could run a little real time check....

HotKeySet("{PAUSE}","ForTheLoveOfGodManWhyIsThisFunctionNameSoLong")
Opt("MouseCoordMode",0)
while 1
$pos = MouseGetPos()
ToolTip($pos[0] & ", " & $pos[1] & @LF & PixelGetColor($pos[0],$pos[1]))
WEnd
Func ForTheLoveOfGodManWhyIsThisFunctionNameSoLong()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
seandisanti

This will have the problem of the mouseover causing the color to change... We need to locate a pixel without the mouse cursor...

Lar.

ok then:

$blah = ControlGetPos("window","",1);just fix the window name and control id
MsgBox(0,"your color",PixelGetColor($blah[0] + $blah[2]/2,$blah[1] + $blah[3]/2)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.