Jump to content

Do until Image not found


Recommended Posts

I'm rather new to Autoit and I'm attempting to create a script that will find an image and click it until that image can no longer be found, then go to the next image and click that image until it's not found. I think i've tried every solution I can think of and I couldn't find anything in forum search that would work.

Here's the current script that simply finds image1, clicks it, finds image2, clicks it.

$image1 = _ImageSearchArea("image1.bmp",1,$ulsearch[0],$ulsearch[1],$lrsearch[0],$lrsearch[1],$x1,$y1,50)
If $image=1 Then
MouseMove($x1, $y1, 20)
MouseClick("left")
sleep(50)
$image1=0
EndIf
$image2 = _ImageSearchArea("image2.bmp",1,$ulsearch[0],$ulsearch[1],$lrsearch[0],$lrsearch[1],$x1,$y1,50)
If $image2=1 Then
MouseMove($x1, $y1, 20)
MouseClick("left")
sleep(50)
$image2=0
EndIf
Link to comment
Share on other sites

So what is the problem, I cant get it since the full code isnt provided

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • Moderators

Hi, gOne, welcome to the forum. Your script is doing exactly what you tell it to, as you have a single If statement. Look at While...WEnd in the help file. I don't do much with ImageSearch, but something like:

$image1 = _ImageSearchArea("image1.bmp",1,$ulsearch[0],$ulsearch[1],$lrsearch[0],$lrsearch[1],$x1,$y1,50)
While $image=1
   MouseMove($x1, $y1, 20)
   MouseClick("left")
   sleep(50)
WEnd

...should work better for you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Just out of curiosity: What kind of application needs to click on different images until they are gone?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

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