Jump to content

Using PixelSearch and If Statements...


Recommended Posts

Hello,

I've been using AutoIT for awhile, but have never had the opportunity or need to use pixel search. I'm not sure I quite understand it, but here is what I'm trying to do...

send("4");Send a keypress
$firstkey1 = PixelSearch(644, 835, 691, 835, 0x5c3316, 10)
If NOT @error Then
  Send("1");Send keypress 1
Else
$secondkey2 = PixelSearch(696, 835, 743, 835, 0x5c3316, 10)
If NOT @error Then
  Send("2");Send key press 2
Else
$thirdkey3 = PixelSearch(748, 835, 795, 835, 0x5c3316, 10)
If NOT @error Then
  Send("3");Send key press 3
EndIf

Here is what I'm trying to accomplish...First, the user hits a button or key - at this point it doesn't matter what it is. After that key is pressed or sent, I want the script to check three different on-screen areas to see if there is a certain color present. If there is a certain color present, I want the script to send the key that is marked by the area that has the color present.

So, if the user hits "4" and then the script detects the specific color on $secondkey2, it should send a keypress to the number 2.

Is this the correct way or should I try something else? Thanks for your help!

Link to comment
Share on other sites

Okay, so I've definitely done something wrong. =)

To try it out, I changed all the ElseIf statements to EndIf...that seems to get the code not erroring out. After that though, I'm stuck...I need it to run through this script section of checking pixels up to three times, one after the other. I tried using a Do...Until $i = 3, but that seemed to not work either.

I'm not having much luck, any help is appreciated. =)

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