Sign in to follow this  
Followers 0
SilverSky

Problem with color

5 posts in this topic

Hi, I would like to create a program that would do something like this:

Check color in x-212 y-157 and if color = red click here(x,y), but if not - click (x,y) and check again color in x-212 y-157, check color untill = red

 

My code, but it doesn't work:

 

$var = PixelGetColor (212,157)

If $var = 0xFF6666 Then
            MouseClick("primary",300,300)
         Else
            MouseClick("primary", 755, 618)
         EndIf

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

?

not clear the exact flow, (the color red should be 0xFF0000 instead of 0xFF6666...)
maybe something like this?

Local $iTargetColor = 0xFF0000 ; the wanted color
Do
    $var = PixelGetColor(212, 157)
    If $var <> $iTargetColor Then MouseClick("primary", 755, 618) ; not the right color
Until $var = $iTargetColor ; repeat this loop until color is the wanted one
MouseClick("primary", 300, 300) ; click here and go ahead...

 

Edited by Chimp
1 person likes this

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok, but how to stop this line for a few seconds "before next "mouseclick" ?

If $var <> $iTargetColor Then MouseClick("primary", 755, 618) ; not the right color

 

or if this possible, write this code on If...Else...EndIf

Edited by SilverSky

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

just insert a delay right after that line,
use the Sleep() function with the wanted delay
Sleep(1000) delays 1 second, Sleep(500) delays half second ...

Local $iTargetColor = 0xFF0000 ; the wanted color
Do
    $var = PixelGetColor(212, 157)
    If $var <> $iTargetColor Then MouseClick("primary", 755, 618) ; not the right color
    Sleep(1000) ; delay of 1000 milliseconds (that is 1 second)
Until $var = $iTargetColor ; repeat this loop until color is the wanted one
MouseClick("primary", 300, 300) ; click here and go ahead...

 

 <..snip>

or if this possible, write this code on If...Else...EndIf

Local $iTargetColor = 0xFF0000 ; the wanted color

While 1
    $var = PixelGetColor(212, 157)

    If $var = $iTargetColor Then

        MouseClick("primary", 300, 300) ; click here...
        ExitLoop ; and go ahead... (exit the While - Wend loop)

    Else

        MouseClick("primary", 755, 618) ; not the right color
        Sleep(1000) ; delay of 1000 milliseconds (that is 1 second)

    EndIf
WEnd ; repeat this loop until color is the wanted one

 

Edited by Chimp
2 people like this

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Thanks for help, like :D

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