Jump to content

Need help fixing script please!


Recommended Posts

This script run for 2-3 hours then I got an error:

Line -1;

Error: Recursion level has been exceeded - autoit will quit to prevent stack overflow.

I need to make it run non stop =/

$sumthing = IniRead(@ScriptDir & "\Config.ini", "Settings", "sumthing", "")

sleep(500)
WindowName()

While sleep(500)
wend

    Func WindowName() 
    If WinExists($sumthing) Then
         nothing()
     else
         Processclose("kkchose1.exe")
         sleep(150)
         Processclose("kkchose2.exe")
         sleep(150)
         Run("anotherthing",@ScriptDir)
         sleep(1000)
         send("^s")
         sleep(2000)
         Run("kkchose2",@ScriptDir)
         sleep(250)
         LogEvent()
         EndIf
     endfunc

Func LogEvent()
        $LogFile = FileOpen(@ScriptDir & "\Logs\kkchose3 restarter.txt", 1)
        FileWriteLine($LogFile, @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Oups kkchose3 crashed... Restarting")
        sleep(100)
        FileClose($LogFile)
        nothing()
EndFunc

    Func nothing()
        sleep(5000)
        WindowName()
    Endfunc
Link to comment
Share on other sites

You shouldn't make functions call each other in a looping pattern, specially when you don't have a terminating condition.

Just reorganize your script code so you don't have functions calling functions calling functions. In this case, I don't think you even need functions at all.

Link to comment
Share on other sites

$sumthing = IniRead(@ScriptDir & "\Config.ini", "Settings", "sumthing", "")

While 1
    If Not WinExists($sumthing) Then
        ProcessClose("kkchose1.exe")
        Sleep(150)
        ProcessClose("kkchose2.exe")
        Sleep(150)
        Run("anotherthing", @ScriptDir)
        Sleep(1000)
        Send("^s")
        Sleep(2000)
        Run("kkchose2", @ScriptDir)

        $LogFile = FileOpen(@ScriptDir & "\Logs\kkchose3 restarter.txt", 1)
        FileWriteLine($LogFile, @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " Oups kkchose3 crashed... Restarting")
        FileClose($LogFile)
    EndIf

    Sleep(500)
WEnd

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