Jump to content

PixelGetColor Problem


Esam
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...