Jump to content

Execute "this" after X loops of a function


Recommended Posts

Hi @Thundorin, and welcome to the AutoIt forums :welcome:
Use Global variables and For...Next loop:

HotKeySet("{ESC}", "ExitApplication")


Global $intCounter = 1


While 1
    Function1()
    If $intCounter > 10 Then Function2()
    Sleep(100)
WEnd

Func ExitApplication()
    Exit
EndFunc

Func Function1()
    ConsoleWrite("Function1 has been ran " & $intCounter & " times." & @CRLF)
    $intCounter += 1
EndFunc

Func Function2()
    ConsoleWrite("Function2!" & @CRLF)
    $intCounter = 1
    ConsoleWrite("Counter is now " & $intCounter & @CRLF)
    Exit
EndFunc

:)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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