MrTam Posted December 2, 2010 Share Posted December 2, 2010 I use pixelgetcolor() on an inactive window. It was return incorrect result. Simple code #include <NomadMemory.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $title="Corel" ; window title global $img[150][150] Opt("PixelCoordMode", 0) If WinExists($title) Then $handle=WinGetHandle($title) ;WinActivate($title) For $i=0 to 99 For $j=0 to 99 $img[$i][$j]=PixelGetColor($i,$j,$handle) Next Next ;draw picture GUICreate("Test",400,300,-1,-1) $graphic=GUICtrlCreateGraphic(50,50,200,200) GUICtrlSetBkColor($graphic, 0xffffff) for $i=0 to 99 for $j=0 to 99 GUICtrlSetGraphic($graphic, $GUI_GR_COLOR, "0x"&Hex($img[$i][$j],6)) GUICtrlSetGraphic($graphic,$GUI_GR_PIXEL,$i,$j) Next Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Else MsgBox(64,"Alert","Window not exist!") exit Endif If I add WinActivate($title) line, every OK. Else, it was return result on active window (wrong!) I use AutoIt lastest version. P.S.: Sorry for may bad English! Link to comment Share on other sites More sharing options...
JohnOne Posted December 2, 2010 Share Posted December 2, 2010 If the window you are trying to retrieve the color from is not visible on screen, pixelgetcolor() will not work. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MrTam Posted December 3, 2010 Author Share Posted December 3, 2010 Thanks for reply! pixelgetcolor() function has hwnd parameter. It's not useful? Link to comment Share on other sites More sharing options...
JohnOne Posted December 3, 2010 Share Posted December 3, 2010 It is useful only if the window is visible Im afraid. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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