Jump to content

How do I do a Nested Pixel Search Loop?


Recommended Posts

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
Link to comment
Share on other sites

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

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

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