Sign in to follow this  
Followers 0
RogerAngel

Problem with if else statement

3 posts in this topic

Hello, I have a little problem, I tried to make a macro to click on an image if come another image that comes randomly and then continue another clicks normally, but this is not happening, can someone help me? Sorry for my poor English.

#include <ImageSearch.au3>

$x=0
$y=0

HotKeySet("{esc}","Close")
HotKeySet("{f1}","Start")
HotKeySet("{f2}","Pause")
_StartUp()

Func _StartUp()
ToolTip("StartUp",0,0)
   while 1
      Sleep(100)
   WEnd
EndFunc

func Close()
   Exit
EndFunc

Func Pause()
   ToolTip("Pause",0,0)
   while 1
      Sleep(100)
   WEnd
EndFunc

func start()
   ToolTip("Started",0,0)
   while 1
   click1()
WEnd
EndFunc

  Func click1()
     While 1
       MouseClick("left",576,299,1,10)
       image1()
      WEnd
   EndFunc

   Func image1()
   While 1
      $image1=_imagesearch("confirm.png",0,$x,$y,100)
      If $image1=1 Then
         clickimage1()
      Else
          Sleep(2500)
         click2()
      EndIf
   WEnd
   EndFunc

   Func clickimage1()
   While 1
      $clickimage= _imagesearch("clickyes.png",0,$x,$y,100)
      If $clickimage1=1 Then
         MouseClick("left",$x,$y,1,10)
            Sleep(2500)
         click2()
      EndIf
   WEnd
EndFunc

Func click2()
     While 1
       MouseClick("left",576,299,1,10)
       image2()
      WEnd
   EndFunc

   Func image2()
   While 1
      $image2=_imagesearch("confirm.png",0,$x,$y,100)
      If $image2=1 Then
         clickimage2()
      Else
          Sleep(2500)
         click3()
      EndIf
   WEnd
   EndFunc

   Func clickimage2()
   While 1
      $clickimage2= _imagesearch("clickyes.png",0,$x,$y,100)
      If $clickimage2=1 Then
         MouseClick("left",$x,$y,1,10)
           Sleep(2500)
         click3()
      EndIf
   WEnd
EndFunc

Func click3()
     While 1
       MouseClick("left",576,299,1,10)
       confirm3()
      WEnd
   EndFunc

   Func image3()
   While 1
      $image3=_imagesearch("confirm.png",0,$x,$y,100)
      If $image3=1 Then
         clickimage3()
      Else
         close()
      EndIf
   WEnd
   EndFunc

   Func clickimage3()
   While 1
      $clickimage3= _imagesearch("clickyes.png",0,$x,$y,100)
      If $clickimage3=1 Then
        MouseClick("left",$x,$y,1,10)
      EndIf
   WEnd
EndFunc

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Your code is pretty cludgy to say the least. Many while...Wend without any exitloop.

Not sure what answer you are expecting.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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