Jump to content

Need a way to return back to a certain point in the script. - (Moved) - (Locked)


Recommended Posts

Hello wonderful people. This is my first post here, i'm really a big fan of AutoIT
Uh, i need help with something

So briefly, i want to evaluate an if statement & when the condition is met i want to move to another if statement but i have two conditions in the second one
1. If condition = true , the code keeps going
2. if condition = false ; Here i want to know what would help me to go back to the first if statement & restart from there ..

Cause i want my code to run in a specific manner where all if conditions must be true, & if they're false they go back to the previous if & continue from there

& Thanks in advance.

;Start
    Local $FindMyColor = PixelSearch(x,y,x,y,color1)
    If Not @Error Then
        MouseClick ("Left",x,y)
    EndIf
    Sleep (2000)
    
    Local $FindMySecondColor = PixelSearch(x,y,x,y,color2)
    If Not @Error Then ; condition being true
        ;Send this & that, click here & there
    ElseIf @Error Then ; condition being false
        ;Here, i want a way go back to ;Start

 

Link to comment
Share on other sites

I figured it out, saw someone mention the Call ("Func_Name") function
so i used it & it worked i just had to put my code in a function so i can call it again if something goes wrong

I tried this in the desktop, did a pixel search on an icon that's fully orange, when i kept that icon in its place it showed me EUREKA ! & when i moved it away, it kept re-scanning in a loop until i moved the icon to its original place

Omegalol()
Func Omegalol()
   MsgBox (0, "Let me try again","Hehe")
   Sleep (5000)

   Local $me = PixelSearch (258, 227,258, 227,0xFF4400)
    If  Not @error Then
      MsgBox (0,"Its working", "EUREKA")
    ElseIf  @error Then
    Call ("Omegalol")
EndIf
EndFunc

 

Link to comment
Share on other sites

1) You don't need to use Call. Just execute the function like this --

Omegalol()

2) This isn't a good way to implement this solution because you are likely to encounter an issue with recursion. See this wiki entry for details.

3) What program are you trying to automate? There are generally better options than using PixelSearch.

Link to comment
Share on other sites

  • Developers

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

25 minutes ago, Danp2 said:

1) You don't need to use Call. Just execute the function like this --

Omegalol()

2) This isn't a good way to implement this solution because you are likely to encounter an issue with recursion. See this wiki entry for details.

3) What program are you trying to automate? There are generally better options than using PixelSearch.

Oo ! it worked too, thank you ! @Danp2 
i'll check the article you sent me 
Oh just a game bot that i want it to check pixels so it knows it's doing the right thing

Link to comment
Share on other sites

  • Developers

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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