Sign in to follow this  
Followers 0
Alexxander

do loop until 10 times

19 posts in this topic

#1 ·  Posted (edited)

Hi all i an new to Autoit

i want to make a script that search for a pic and click it 

and repeate that for 10 times i had readed the help doc and some postes in the forums but no luck

the search and click itself is working but i cant get the loop to work

any ideas ?

#include <ImageSearch.au3>

$x = 0
$y = 0


$NUM = 0
While $NUM <= 10
   
Func start()
  
  Do
$Search = _ImageSearch('pic.bmp', 0, $x, $y, 0)

if $Search = 0 Then sleep (1000)
Until $Search = 1
If $Search = 1 Then
 MouseMove($x, $y,10)
 MouseClick("left", $x, $y, 1)
 EndIf
EndFunc


WEnd

when i run this code it give the following error

C:UsersAdministratorDownloadsImageSearchImageSearchtut.au3 (10) : ==> "While" statement has no matching "Wend" statement.:
Func start()
Edited by alexander95

Share this post


Link to post
Share on other sites



Which program do you try to automate?

Often there are faster and more reliable ways to do what you want to do.


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

Which program do you try to automate?

Often there are faster and more reliable ways to do what you want to do.

 

Because have a function inside a while wend loop.

It is not allowed.

 

Please guys just tell me how to fix it

i want to use this method 

thank u


Share this post


Link to post
Share on other sites

Alexander95,

this is no "I have a problem please solve it for me" forum. We ask questions for a reason. So please give us some answers and we will see how we can help you.


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

alexander95,

JohnOne has told you what is wrong with your script; water asked for more information so he could perhaps offer some more focused help. And you complain? :o

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

 

this is no "I have a problem please solve it for me" forum. We ask questions for a reason. So please give us some answers and we will see how we can help you.

 

bro i want to learn this method 

there is no program i want to run on it i just wanna learn it

now i am seeing the autoit help doc i used all the loop methods but they are giving errors 

 

any ideas ?

Edited by alexander95

Share this post


Link to post
Share on other sites

You have 2 "ifs" and only one Endif. Either you put another EndIf in or you use ElseIf. (I think)

And your func starts in the middle of a loop.

Share this post


Link to post
Share on other sites

alexander95,

JohnOne has told you what is wrong with your script; water asked for more information so he could perhaps offer some more focused help. And you complain? :o

M23

 

i am not complaining he is doing a favor for me and i am so thankful

but the thing is that i want to learn this type of automation 

thank u guys


Share this post


Link to post
Share on other sites

To learn AutoIt please have a look at the wiki. There is a tutorial section which is a good place to start.


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

You have 2 "ifs" and only one Endif. Either you put another EndIf in or you use ElseIf. (I think)

And your func starts in the middle of a loop.

 

i made them to i still have the following error

 

C:UsersAdministratorDownloadsImageSearchImageSearchtut.au3 (12) : ==> "Do" statement has no matching "Until" statement.:

Func start()

 

thank u for attempting to help me guys it is  so apriciated


Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

If you use "Do", you will have to have "Until" somewhere. Somewhere where AutoIT can find it, not hidden in another func or something.

Do <- This does the following command over and over again

Until <- Until a certain criteria is matched.

For example:

Do

   $variable = $variable + 1

Until $variable = 4

This would add 1 to the variable "Until" the variable equals 4.

I hope you understand what i mean.

Edited by bleh

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Hopefully this is clear as mud.

But I'll let you fill in the missing dots, etc.

While x < y

      .....

      Start()

      ......

Wend


Func Start()

     ........
     Do
         .....
         .....
     Until x

     ........

EndFunc

You really need to try some tutorials and carefully read the Help file though.

And probably put in the sleep that JohnOne mentioned.

Edited by TheSaint
1 person likes this

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Use this code.

#include <ImageSearch.au3>
$x = 0
$y = 0
$NUM = 0
While $NUM <= 10
    start()
    Sleep(10)
WEnd
Func start()
    Do
        $Search = _ImageSearch('pic.bmp', 0, $x, $y, 0)
        If $Search = 0 Then Sleep(1000)
    Until $Search = 1
    If $Search = 1 Then
        MouseMove($x, $y, 10)
        MouseClick("left", $x, $y, 1)
    EndIf
EndFunc   ;==>start
1 person likes this

Share this post


Link to post
Share on other sites

You'll have to increment $NUM else it will never reach 10 and you will loop forever.

Also, just FYI, starting at 0 and looping until <= 10 is actually 11 rounds...assuming were talking integers here.

Share this post


Link to post
Share on other sites

thank you guys for help really appreciated ...


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