Jump to content

In Need of Some Guidance


Recommended Posts

Hello all. I was wondering if anyone could help me or point me in the right direction. What i'm trying to do is PixelSearch for a color, when the color is found click the location, and if it's the correct location i'm looking for a specific window will appear. Where i'm stuck at for the time being is that there are quite a bit of these colors on the screen so when PixelSearch is finding it it'll click it but hang there because i don't know how to tell it to keep searching and clicking until either the specific window exists (checking with If WinActive) or until the entire rectangle for the PixelSearch has been searched through without the window popping up. I've been searching for a while now and haven't found anything that is specific to what i'm asking or helped so i've come to the experts here at the forums. Thank you in advance! -Dan

Link to comment
Share on other sites

I dont believe you searched at all, because I just did and there are hundreds of results.

Nonetheless.

"i don't know how to tell it to keep searching and clicking until either the specific window exists"

I assume since you have been searching that you have tried at least something.

You need to put the code you have to find the pixel colour, in a loop, also in that loop should be your code to check for the window.

There are a few different loops, you can take your pick from, saerch loops in help file

While wend loop

For next loop

Do Until loop

You can exit any of those loops if your windoe exists, with the ExitLoop keyword.

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

Monkey's are, like, natures humans.

Link to comment
Share on other sites

You probably did search and you probably did find 100's, I have too, but nothing I came across, that I understood anyways, explained how to search for the next pixelcolor if after the mouseclick the window did not become active. I have tried the help file, and I believe I need to use the For loop, or perhaps a Case, but I don't quite understand what the help file is telling me about these. All I would like the script to do is Search the coordinates for the color, mouseclick if found, check to see if a specific window is then active, and if not, continue searching through the coordinates where it last found the color it tried until either the window exists or none of the colors it found and clicked had the window become active.

Link to comment
Share on other sites

For $y = 100 To 200
    For $x = 100 To 200
        If PixelGetColor($x, $y) = 12345678 Then
            MouseClick("left", $x, $y, 1)
            ;Sleep(1000)
            If WinActive("Specific Window") = 1 Then
                ExitLoop 2
            EndIf
        EndIf
    Next
Next

Creating your first nested statements feels a little odd, if you do not have any help or prior knowledge, but this should be understandable.

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