Sign in to follow this  
Followers 0
OminousIdol

Overstack?

9 posts in this topic

I am running Functions for a long period of time... After awhile I will get a Overstack Flow Error because of Sleep... How could I fix this?

WinActivate ("Mythia - Mozilla Firefox", "")
Sleep(2000)

Call ("FindAttack")

Func FindAttack()
    Send("^f")
        Sleep(500)
    Send("Attack")
        Sleep(500)
    Call("Color")
EndFunc

Func FindWait()
    Send("^f")
        Sleep(500)
    Send("Wait here a while.")
        Sleep(500)
    $Wait = PixelSearch(527, 257, 803, 562, 0x38D878)

    If @error Then
        Call("Tab7")
    Else
    MouseClick("left", $Wait[0], $Wait[1])
        Sleep(20000)
    Call ("Tab7")
    EndIf
EndFunc

Func Color()
$coord = PixelSearch(530, 484, 740, 557, 0x38D878)

    If @error Then
        Call ("FindWait")
    Else
        MouseClick("left", $coord[0], $coord[1])
            Sleep(20000)
        Call ("Tab7")
    EndIf

EndFunc

Func Tab7()
$Back = PixelSearch(344, 204, 733, 503, 0xD4D0C8)

    If @error Then
        Call ("FindAttack")
    Else
    MouseClick("left", $Back[0], $Back[1])
        Sleep(20000)
    Call("FindAttack")
    EndIf
EndFunc

Thanks

Share this post


Link to post
Share on other sites



Everytime you call a function, inside of another function, that goes to the next one without stopping, it overstacks the program.

This will do the same thing.

StartFlow()
Func StartFlow()
   KeepFlow()
EndFunc
Func KeepFlow()
   StartFlow()
EndFunc

It's a never ending function that overstacks and terminates. Just try to be a bit more clean with the code, and not link to each other.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok... so how would I clean the code up then?

Edited by OminousIdol

Share this post


Link to post
Share on other sites

That is something you need to figure out, if I go out giving you the answers you will never learn. Run this through Tidy, and make sure there is no possible explanation for an infinite loop. That's all I can say.

AutoIt Smith

Share this post


Link to post
Share on other sites

But the thing is that I need it to loop forever... hmm would it be smart to to call a differnt au3 scripts? Then it would be opening and closing the functions so it wont cause a overflow?

Thanks

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Don't use CALL()!!!

Also, look into using While..WEnd and Do..Until for infinite loops.

Edited by Saunders

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

What you are doing does not require any function calls. You appear to want something close to this:

WinActivate('Mythia - Mozilla Firefox')
Sleep(2000)

While 1

; Find attack
    Send('^f')
    Sleep(500)
    Send('Attack')
    Sleep(500)

; Colour
    $Coord = PixelSearch(530, 484, 740, 557, 0x38D878)

    If Not @Error Then
        MouseClick('', $Coord[0], $Coord[1])
        Sleep(20000)
    Else
; Find wait
        Send('^f')
        Sleep(500)
        Send('Wait here a while.')
        Sleep(500)
        $Wait = PixelSearch(527, 257, 803, 562, 0x38D878)
        If Not @Error Then
            MouseClick('', $Wait[0], $Wait[1])
            Sleep(20000)
        EndIf
    EndIf

; Tab 7
    $Back = PixelSearch(344, 204, 733, 503, 0xD4D0C8)
    If Not @Error Then
        MouseClick('', $Back[0], $Back[1])
        Sleep(20000)
    EndIf

WEnd

While 1..WEnd gives you an infinite loop. As you are not continually entering functions without exiting them again, you will receive no stack overflow errors.

Edited by LxP

Share this post


Link to post
Share on other sites

You're too nice Alex. :P

Share this post


Link to post
Share on other sites

Nice Fix

And remember there is almost no need to Call()

Call would actually be nessesary when testing script when you type the function. All other ways should not involve using call

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