Sign in to follow this  
Followers 0
d3adlin3

PixelGetColor Problems

3 posts in this topic

Hi,

Im having problems with PixelGetColor.

Im trying to get the colour of a button inside a window and if its Black todo X.

When I currently do PixelGetColor it doesnt detect the colour even thoe its definatly the right co ords; I think the problem is due to PixelGetColor not being in 'Client Co Ord 'mode? I just dont know how to turn that mode on (if that is the problem).

Heres the function with the problem, and the settings linked with it:

$WHConnectedTitle = "connected"
$WHAX=40
$WHAY=13
$WHAColour="000000"

AutoItSetOption ( "PixelCoordMode", 0 )
Opt("GUICoordMode", 1)
Opt("MouseCoordMode", 2) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func ConnectWH()

    WinActivate($WHConnectedTitle)               ;; Activate Main WH Window
    Sleep(1000)                           ;; Pause
    MouseClick("Left", 17, 12)             ;; Select Green Button

    $WHAColour_var = PixelGetColor($WHAX,$WHAY);; Get Colour of A Button
    $WHAColour_hex = Hex($WHAColour_var, 6)    ;; Converts it to Hex

If $WHAColour_hex = $WHAColour Then        ;; 
    MsgBox(1,"True","True")                      ;;
Else                                                ;; Else
    MsgBox(1,"False","False")                      ;; 
    
EndIf

    
EndFunc

Thanks for any help

D3ADLiN3

Share this post


Link to post
Share on other sites



Look at Opt() in the help file.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

Im having problems with PixelGetColor.

Im trying to get the colour of a button inside a window and if its Black todo X.

When I currently do PixelGetColor it doesnt detect the colour even thoe its definatly the right co ords; I think the problem is due to PixelGetColor not being in 'Client Co Ord 'mode? I just dont know how to turn that mode on (if that is the problem).

Heres the function with the problem, and the settings linked with it:

$WHConnectedTitle = "connected"
$WHAX=40
$WHAY=13
$WHAColour="000000"

AutoItSetOption ( "PixelCoordMode", 0 )
Opt("GUICoordMode", 1)
Opt("MouseCoordMode", 2) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func ConnectWH()

    WinActivate($WHConnectedTitle)          ;; Activate Main WH Window
    Sleep(1000)                         ;; Pause
    MouseClick("Left", 17, 12)           ;; Select Green Button

    $WHAColour_var = PixelGetColor($WHAX,$WHAY);; Get Colour of A Button
    $WHAColour_hex = Hex($WHAColour_var, 6)  ;; Converts it to Hex

If $WHAColour_hex = $WHAColour Then      ;; 
    MsgBox(1,"True","True")                 ;;
Else                                        ;; Else
    MsgBox(1,"False","False")                    ;; 
    
EndIf

    
EndFunc

Thanks for any help

D3ADLiN3

PixelCoordMode Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the current active window:

0 = relative coords to the active window

1 = absolute screen coordinates (default)

2 = relative coords to the client area of the active window

if you think that's the problem, that's how you do it. as it is right now, with mode=0, you would have to have defined your coordinate relative to your active window. Since it looks like your mouse coords are in mode 2, which is rel. to client area, that may be the problem

Edited by Leighwyn

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  
Followers 0