Jump to content

Recommended Posts

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

Posted

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:

  Reveal hidden contents

 

Posted
  On 7/7/2013 at 2:06 PM, water said:

Which program do you try to automate?

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

 

  On 7/7/2013 at 2:16 PM, JohnOne said:

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

Posted

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:

  Reveal hidden contents

 

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)
  On 7/7/2013 at 3:01 PM, water said:

 

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

Posted

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.

Posted

  On 7/7/2013 at 3:02 PM, Melba23 said:

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

Posted

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:

  Reveal hidden contents

 

Posted
  On 7/7/2013 at 3:03 PM, bleh said:

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

  Quote

 

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

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

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

  Reveal hidden contents

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

  • Solution
Posted

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
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...