Jump to content

How to cycle through a PixelSearch


Recommended Posts

Hello,

I've wrote a fairly straight forward script that will search an area of the screen and then left click on apart of that area should it find a certain color/pixel. 

I have a small issue where by within the area, multiple pixels of the same color will appear, the script will continue to click on the same pixel over and over again. Is there a way so that it will cycle through all the results and click on each one for a given time period then move onto the next, as apose to clicking on the same spot forever. I have used timers before and that shouldn't be an issue, its more the having it stop clicking, or ignoring the current pixel its clicking and then moving onto the next one (same pixel color within same area).


Hopefully this makes sense.

[autoit]

HotKeySet("{ESC}", "END_EXIT")
HotKeySet("+1", "start")
While 1
    Sleep(100)
 WEnd

func start()
   while 1
$location = PixelSearch( 631, 175, 1181, 597, 0xFF0000)
If IsArray ($location) = 1 Then
    MouseClick ('left', $location[0], $location[1], 1, 0)
 EndIf
 WEnd
EndFunc

 func END_EXIT()
 Exit
 EndFunc


 

[/autoit]

Edited by Annonyreeder
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

×
×
  • Create New...