Sign in to follow this  
Followers 0
Lanphrost

Looping the PixelSearch command?

7 posts in this topic

#1 ·  Posted (edited)

Alright, so my problem is basically that I want the program to constantly check to see if there's a specific color in a certain spot and then send a command if that color is present. Unfortunately, I can't tell if it's looping, or if it simply checks once and then gives up. I'm guessing the latter.

WinWaitActive( "firefox" )
$coord = PixelSearch( 145, 593, 292, 448, 006699, 10)
If Not @error Then
    MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf

As far as I can tell, if the color is there when the window opens it'll give me a dialogue of where it first detected the color. What I need it to do is to constantly check that space for the color and then "Send ("{TAB}")" which I haven't tried because I can't get my debug mode (the above snippet) working.

Any help or advice would be appreciated.

Edited by Lanphrost

Share this post


Link to post
Share on other sites



Why don't you have it write the color it sees in that spot to a log? that way you know if it loops because you'll have multiple entries rather than just one, you can use PixelGetColor() and _FileWriteLog()


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites

Oh, now I see it, I was supposed to use 0, 10

And how would I loop that? I've tried a few variations, but all of them have failed so far.

Share this post


Link to post
Share on other sites

if you want to loop until it finds the pixel.

WinWaitActive("firefox")
While 1
    $coord = PixelSearch(145, 593, 292, 448, 006699)
    If Not @error Then
        MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
        Exit
    EndIf
    Sleep(10)
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Alright, the color seems to be off, but I can't figure out which color it is, and I want it to loop even after it's found the color, is that possible?

Edit 2:

Got the thing to loop, removing 'exit' was easy enough. Now I just need to figure out what color it is that I'm looking for.

Edited by Lanphrost

Share this post


Link to post
Share on other sites

And now it's working, thanks for all the help!

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