Jump to content

Window Info provides incorrect color on Windows 8?


Recommended Posts

I tried using the AutoIt Window Info tools (both x86 and x64) to identify the color of specific pixels being displayed in the browser (Chrome) window.  The reported color hex values bear no resemblance to the actual colors under the Finder Tool target cursor.  For instance, as I drag the Finder Tool across the blank area in the text box where I'm writing this message, I see values 0xFFFFFF (expected), 0x204066, 0x1C3B5F, 0x142B46, etc.  The Title and Class are reported correctly, and the other information seems right.  Is there something about Windows 8 or Chrome that prevents the Window Info Tool from accessing the pixel color?

UPDATE: I just tried it on an empty notepad.exe window.  Same results - despite sampling a blank white text area, the color reported varies wildly.  What's up with that?

Link to comment
Share on other sites

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=Working Exe's\pixelgetcolorandhexParksModified.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstants.au3>
#include <date.au3>

Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 4) ; set title matchmode to advanced

Global $xoffset = 37
Global $yoffset = 23
Global $wposx, $wposy, $DT, $cWIN, $xcalcL, $xcalcR, $ycalc, $cpos, $pos, $tpos, $hexV, $pcolor
Global $title = "Your Title Here"

HotKeySet("{ESC}", "Terminate") ; a way out of this
;HotKeySet("!f", "_color"); check for color

$pGUI = GUICreate($title, 300, 13, -1, -1, $WS_POPUP);Make a GUI next to mouse
$startLAB = GUICtrlCreateLabel(" X: 0000, Y: 0000", 0, 0, 300, 13);Fill GUI with coords
GUICtrlSetBkColor($startLAB, 0xCCFFFF);Background color of GUI window

WinSetOnTop($pGUI, "", 1);Make GUI topmost

GUISetState(@SW_SHOW)

While 1
    ;_checkWIN()
    _nMGP()
WEnd

Func _nMGP()
    Local $_cpos = MouseGetPos()
    Sleep(0010)
    $pcolor = PixelGetColor($_cpos[0],$_cpos[1])
    $pos = MouseGetPos()
    GUICtrlSetData($startLAB, ' X: ' & $pos[0] & ', Y: ' & $pos[1] & ' HEX: ' & HEX($pcolor,6) & ' DEC: ' & $pcolor)
    If $DT = 1 Then
        $xcalcR = .95 * @DesktopWidth
        $xcalcL = .05 * @DesktopWidth
        $ycalc = .90 * @DesktopHeight
        If $pos[1] > $ycalc Then
            $wposy = $pos[1] - $yoffset * 2 ; If too close to bottom of screen position above mouse pointer
        Else
            $wposy = $pos[1] + $yoffset ; Position label beneath the mouse pointer
        EndIf
        If $pos[0] > $xcalcR Then ; If too close to right side of screen move it
            $wposx = $pos[0] - $xoffset * 3
        ElseIf $pos[0] < $xcalcL Then ; If too close to left side of screen move it
            $wposx = $pos[0] + 10
        Else
            $wposx = $pos[0] - $xoffset ; Use normal offsets for positioning label
        EndIf
    Else
        _clientmouse()
    EndIf
    WinMove($title, "", $wposx, $wposy) ; Move the label appropriate to follow the mouse
EndFunc   ;==>_nMGP

;Func _checkWIN()
;    $cWIN = WinGetTitle("[ACTIVE]")
;    If $cWIN <> $title Then
;        TrayTip("", $cWIN, 30)
;        Opt("MouseCoordMode", 0)
;        $DT = 0
;    Else
;        TrayTip("", "DESKTOP", 30)
;        Opt("MouseCoordMode", 1)
;        $DT = 1
;    EndIf
;EndFunc   ;==>_checkWIN

Func _clientmouse()
    Opt("MouseCoordMode", 1)
    $tpos = MouseGetPos()
    $cpos = WinGetPos($cWIN)
    $xcalcR = .95 * $cpos[2]
    $xcalcL = .05 * $cpos[2]
    $ycalc = .90 * $cpos[3]
    If $tpos[1] > $ycalc Then
        $wposy = $tpos[1] - $yoffset * 2 ; If too close to bottom of screen position above mouse pointer
    Else
        $wposy = $tpos[1] + $yoffset ; Position label beneath the mouse pointer
    EndIf
    If $tpos[0] > $xcalcR Then ; If too close to right side of screen move it
        $wposx = $tpos[0] - $xoffset * 3
    ElseIf $tpos[0] < $xcalcL Then ; If too close to left side of screen move it
        $wposx = $tpos[0] + 10
    Else
        $wposx = $tpos[0] - $xoffset ; Use normal offsets for positioning label
    EndIf
EndFunc   ;==>_clientmouse

;Func _color()
;    Local $_cpos = MouseGetPos()
;    Local $pcolor
    ; - ;$pcolor = PixelGetColor($_cpos[0],$_cpos[1])
;    $hexV = "0x" & Hex($pcolor,6)
;    Local $fOpen = FileOpen(@ScriptDir & "\color.txt",1)
;    FileWrite($fOpen,@CRLF & _NowDate() & " " & _NowTime() & " : " & "X: " & $_cpos[0] & _
;        "," & "Y: " & $_cpos[1] & " | " & "Color: " & $hexV)
;    FileClose($fOpen)
;EndFunc

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

Try this. It is a stand alone pixel get color and coords. Notice how the coordinates will change if you select a window. The coords you get when you first run the script are accurate so long as you don't click anything.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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...