Jump to content

PixelGetColor, and noticing a change


Recommended Posts

HotKeySet("h", "SetColor")

While(1)
    WinActive("Paint")
WEnd

Func SetColor()
    $var = PixelGetColor( 640 , 400 )
    $var2 = PixelGetColor( 640 , 400 )
    While (1)
        $var2 = PixelGetColor( 640 , 400 )
        If $var2 NOT = $var Then
            MsgBox(0,"The old color was", Hex($var, 6))
            MsgBox(0,"The new color is", Hex($var2, 6))
            ExitLoop
        EndIf
    WEnd
EndFunc

Sleep(20000000)

Basically right now when I set the color (by pressing H), it sets $var to the color in the middle of my screen. Then when the pixel color in the middle of the screen changes it should display the messages, and wait for a new color to be set.

It does this just fine with black and white, but if I use like red and yellow the display messages do not appear. Anyone know why?

Thanks.

Link to comment
Share on other sites

This what you're trying to do?

Global $var
Global $Coords[2] = [640, 400]


HotKeySet("h", "SetColor")

While 1
    Sleep(20)
    If PixelGetColor($Coords[0] , $Coords[1]) <> $var And $var <> 0 Then 
        Sleep(500)
        MsgBox(0, "", "Changed")
    EndIf
WEnd

Func SetColor()
    $var = PixelGetColor($Coords[0] , $Coords[1])
EndFunc
Link to comment
Share on other sites

Global $var
Global $Coords[2] = [640, 400]


HotKeySet("h", "SetColor")



Func SetColor()
    $var = PixelGetColor($Coords[0] , $Coords[1])
    While 1
    Sleep(20)
    If PixelGetColor($Coords[0] , $Coords[1]) <> $var Then
        Sleep(100)
        MsgBox(0, "", "Changed")
        ExitLoop
    EndIf
WEnd
EndFunc

Sleep(2000000000)

I basically just moved the loop into the function, and it works just like I wanted it to. Thanks!

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