Jump to content
Sign in to follow this  
stagius24

question about pixel color

Recommended Posts

stagius24

Func Start()

while 1

$var = PixelGetColor( 877 , 167 )

$var1 = PixelGetColor( 829 , 136 )

while $var <> $var1

MsgBox(0,"different", $var)

Msgbox(0,"different", $var1)

Sleep(5000)

WEnd

Msgbox(0,"same", $var)

Msgbox(0,"same", $var1)

sleep(500)

wend

EndFunc

I m in the process of learning, so please pardon my ignorant.

I m trying to write a script that can tell the different of pixel over and over again. The problem with this script is they tend to recognize the two pixels only ONE. After that, the pixelgetcolor function did not update the new pixel color again even though I present a different pixel.

THe question is how I gonna write this script so that the $var = pixelcolor get updated everytime, over and over again.

Thank you

Share this post


Link to post
Share on other sites
SmOke_N

Func Start()
    Local $var, $var1
    While 1
        $var = PixelGetColor( 877 , 167 )
        $var1 = PixelGetColor( 829 , 136 )

        While $var <> $var1
    ; Do something here
            Sleep(5000)
    ; If we never check while we are in this loop
    ; Then $var and $var1 values never change, so we'll be stuck here
            $var = PixelGetColor( 877 , 167 )
            $var1 = PixelGetColor( 829 , 136 )
        WEnd
; Do something here?
        Sleep(500)
    Wend
EndFunc

But really, it looks like you just need a conditional statement:

Func Start()
    Local $var, $var1
    While 1
        $var = PixelGetColor( 877 , 167 )
        $var1 = PixelGetColor( 829 , 136 )

        If $var <> $var1 Then
; Do something here
            Sleep(5000)
        Else
; Do something that you would do if they were equal
            Sleep(500)
        EndIf
    Wend
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
stagius24

What is the use of local in your script? I press F1, and it sound complicated to me. Can you explain why you declare $var, var1 as a variable, constant?

Share this post


Link to post
Share on other sites
SmOke_N

What is the use of local in your script? I press F1, and it sound complicated to me. Can you explain why you declare $var, var1 as a variable, constant?

http://www.autoitscript.com/forum/index.php?showtopic=24062

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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  

×