Jump to content

Problem with color


Recommended Posts

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

 

Link to comment
Share on other sites

?

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

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
Share on other sites

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

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

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