Jump to content
aa2zz6

How do I do a Nested Pixel Search Loop?

Recommended Posts

aa2zz6

How do I nest multiple PixelSearch like the code below so if one fails they both do? Thanks again for any help.

$coord = PixelSearch( 24, 85, 1238, 916,0xF6D370,1)

If Not @error Then
     MouseMove($coord[0],$coord[1],0)
Sleep(500)
MouseClick("left")
sleep(5000)
EndIf

Edited by aa2zz6

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

Which program do you try to automate?
Most of the time there are more reliable ways to do what you want to achieve by using other AutoIt functions.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
aa2zz6

The idea was to create a short application that searches for a certain pixel on Google Earth and if that particular pixel wasn't found then it would set a random movement. I work a lot with Google Earth in real-life and I thought it would be neat to show my co-workers something different. : ) 

The idea is to find the pixel and if it's not found then we use a MouseClickDrag(), but when the pixel is found the MouseClickDrag keeps on going. What would be the best way to handle a situation like this. Maybe split these the code into two different functions Func(GooglePixel) And Func(MoveMouse) and if the pixel is not found then the GooglePixel would somehow tell the Func(MoveMouse) to move either Down to the Right depending on how the coordinates are set.

$i = 0
While $i <= 10
       MouseClickDrag("left", 689, 501, 686, 206)
    Sleep(1000)
  $coord = PixelSearch(24, 85, 1238, 916,0xA8B679,2)
  If Not @error Then
    MouseClick("primary", $coord[0], $coord[1], 1, 0)
  EndIf
    $i = $i + 1
    Sleep(2000)

WEnd

 

Share this post


Link to post
Share on other sites
JohnOne

Array full of coordinates.

Loop through array With a For...Next loop, Calling PixelSearch with each set of coordinates from the array, if one sets @error then return false, no point in checking the rest, return true if loop ends.

Edited by JohnOne
  • Like 1

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
aa2zz6

Thanks for the help and responses!

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

×