Sign in to follow this  
Followers 0
g0ne

Do until Image not found

7 posts in this topic

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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
While $image=1 should be While $image1=1, no?

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Yes, typo on my part.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Actually, a typo on the OP's part. You did start to viralize it though, probably by copying/pasting the original code snippet in order to modify/correct it.. ;)


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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
Sign in to follow this  
Followers 0