RealisT Posted November 23, 2010 Share Posted November 23, 2010 Windows XP SP3Script creates a GUI Form with background Color A and a textless Label on it with background Color B. With me so far?Script returns PixelGetColor info wherever the mouse clicks over the label. Here's the wierd part:Although the label is all the same color (or so I thought), clicking in most places over the label returns the label's color, but in other places it returns the color of the form underneath it. This makes the PixelGetColor unuseable for me even for a simple one-color object.(The issue is repeatable; you just need to find the areas which do this.)What is the problem? Is the label 'porous', or is PixelGetColor not always looking at the top (visible) layer?Is there an adjustment or workaround for this? I just need reliable color info returned over different labels.Here is the code:expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("MouseCoordMode", 2) Global $formBGColor = 0x669999 Global $boardBGOffColor = 0xBCDCFF $formWidth = Int(@DesktopWidth * 0.8) $formHeight = Int(@DesktopHeight * 0.8) $formLeft = Int((@DesktopWidth - $formWidth) / 2) $formTop = Int((@DesktopHeight - $formHeight) / 2) $mainForm = GUICreate("TEST", $formWidth, $formHeight, $formLeft, $formTop) GUISetBkColor($formBGColor) $boardBGPanelWidth = 450 $boardBGPanelHeight = 600 $boardBGPanelLeft = 350 $boardBGPanelTop = 36 $boardBGPanel = GUICtrlCreateLabel("", $boardBGPanelLeft, $boardBGPanelTop, $boardBGPanelWidth, $boardBGPanelHeight) GUICtrlSetBkColor($boardBGPanel, $boardBGOffColor) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_PRIMARYDOWN $mouse = MouseGetPos() $mouseColor = PixelGetColor($mouse[0], $mouse[1]) If $mouse[0] > $boardBGPanelLeft And $mouse[0] < $boardBGPanelLeft + $boardBGPanelWidth Then If $mouse[1] > $boardBGPanelTop And $mouse[1] < $boardBGPanelTop + $boardBGPanelHeight Then ConsoleWrite("Color = " & Hex($mouseColor, 6) & @CRLF) EndIf EndIf EndSelect Wend Exit Link to comment Share on other sites More sharing options...
Tvern Posted November 23, 2010 Share Posted November 23, 2010 Take another look at AutoItSetOption("MouseCoordMode", 2) What coordmode does PixelGetColor() use? Link to comment Share on other sites More sharing options...
RealisT Posted November 23, 2010 Author Share Posted November 23, 2010 Take another look at AutoItSetOption("MouseCoordMode", 2) What coordmode does PixelGetColor() use? Oops. Everything was responding so well, coordinate-wise, until this one issue, so I thought my settings were fine. But this is the first demand for pixel-related functions. My bad. Works OK now with AutoItSetOption("PixelCoordMode", 2). Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now