Sign in to follow this  
Followers 0
MrTam

Pixelgetcolor() problem

4 posts in this topic

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! :graduated:

Share this post


Link to post
Share on other sites



Thanks for reply!

pixelgetcolor() function has hwnd parameter. It's not useful?

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