Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 02:24

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help] [AutoIT] Imagesearch stack overflow

Discussion on [Help] [AutoIT] Imagesearch stack overflow within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Mar 2013
Posts: 38
Received Thanks: 5
[Help] [AutoIT] Imagesearch stack overflow

Hey everyone I'm playing around with auto it and I'm new. I haven't realy searched a lot for my problem but I wrote a skripts that is running. Its finding images clicking on them and everythin that I want but its running like 20-30 minutes or less or more and its stops, the scripts just exit and in the script I get this error:
"C:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3" (34) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:
Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)

Can anyone explain to me how to fix it, how the scripts doesn't stop after certain amount of time. Thanks in advance. I'm sorry for my bad english and I'm sorry if there was a thread about it and it has been answered. I haven't searched a lot.
hanover001 is offline  
Old 08/25/2015, 22:44   #2

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
Your problem is recursion. Recursion simply means that a function calls itself again and again. But there must be a break condition, else your function will call itself endlessly. For example:

PHP Code:
Global $counter 0
Recursion
()

Func Recursion()
$counter += 1
ConsoleWrite
($counter & @CRLF)
Recursion()
EndFunc 
A correct use of recursion would be for example:

PHP Code:
Global $counter 0
Recursion
()

Func Recursion()
$counter += 1
If $counter >= 10 Then Return
ConsoleWrite($counter & @CRLF)
Recursion()
EndFunc 
So if you call your ImageSearch function over and over again, after some time AutoIt can't handle to amount of recursive calls anymore and that is the cause of your error
Moneypulation is offline  
Thanks
1 User
Old 08/26/2015, 00:01   #3
 
elite*gold: 0
Join Date: Mar 2013
Posts: 38
Received Thanks: 5
Okey now I get it what is the real problem but I still dont undestand how to fix it maybe because I'm new with all the coding. What do I have to do I have to put a counter on every function?

Thanks for the fast reply
hanover001 is offline  
Old 08/26/2015, 00:03   #4

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
Quote:
Originally Posted by hanover001 View Post
Okey now I get it what is the real problem but I still dont undestand how to fix it maybe because I'm new with all the coding. What do I have to do I have to put a counter on every function?

Thanks for the fast reply
Post your code here. Else we can't really figure out the problem
Moneypulation is offline  
Old 08/26/2015, 01:01   #5
 
elite*gold: 0
Join Date: Mar 2013
Posts: 38
Received Thanks: 5
#include <ImageSearch.au3>

HotKeySet("{F1}", "Main")
HotKeySet("{F3}", "stop")
HotKeySet("{F2}", "pause")

Global $x = 180
Global $y = 100
Global $1x, $2x, $3x, $4x, $5x, $6x, $7x, $8x, $9x, $10x, $11x, $12x, $13x, $14x, $15x, $16x = @DesktopHeight
Global $1y, $2y, $3y, $4y, $5y, $6y, $7y, $8y, $9y, $10y, $11y, $12y, $13y, $14y, $15y, $16y = @DesktopWidth


Func Main()
While 1
$lookmap = _ImageSearch("map.png", 1, $4x, $4y, 0)
If $lookmap = 1 Then
MouseClick("left", $4x + 25 + (Random(0, $x)), $4y + 50 + (Random(0, $y)))
Sleep(200)
_wait()
EndIf
WEnd
EndFunc



Func _wait()
While 1
Sleep(200)
$gotopoint = _ImageSearch("gotopoint.png", 1, $5x, $5y, 0)
If $gotopoint = 1 Then
golditem()
Else
Main()
EndIf
WEnd
EndFunc

Func item()
While 1
$item = _ImageSearch("items.png", 1, $6x, $6y, 0)
If $item = 1 Then
MouseClick("left", $6x, $6y, 1)
Sleep(200)
waititemtocollect()
Else
_wait()
EndIf
WEnd
EndFunc

Func golditem()
While 1
$golditem = _ImageSearch("goldenitems.png", 1, $7x, $7y, 0)
If $golditem = 1 Then
MouseClick("left", $7x, $7y, 1)
Sleep (200)
waititemtocollect()
Else
item()
EndIf
WEnd
EndFunc

Func waititemtocollect()
While 1
$waititemtocollect = _ImageSearch("waittocollect.png", 1, $2x, $2y, 0)
If $waititemtocollect = 0 Then
golditem()
EndIf
WEnd
EndFunc


While 1
Sleep(100)
WEnd

Func pause()
While 1
Sleep(100)
WEnd
EndFunc

Func stop()
Exit
EndFunc
hanover001 is offline  
Old 08/26/2015, 11:44   #6

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
The problem is that you call functions over functions without return. Try to recode it that it only has one main loop like:

Func main ()

While 1
$item = Golditem ()
If $item = True Then
Collect ()
Waitforcollect ()
Endif
Sleep (200)
Wend

Endfunc

Your other functions can have while loops too but they must have a break condition so that you will return to your main loop.
Moneypulation is offline  
Thanks
1 User
Old 08/26/2015, 18:23   #7
 
elite*gold: 0
Join Date: Mar 2013
Posts: 38
Received Thanks: 5
Okey thanks for the help I will try recoding it.

edit: well I tryed several times recoding it but I cant manage to make it so it doesnt stop
hanover001 is offline  
Reply


Similar Threads Similar Threads
Stack Overflow
06/03/2015 - AutoIt - 6 Replies
Hallo, ich programmiere gerade Tic Tac Toe mit GUI und einer random KI. Leider kommt bei mir immer Recursion level has been exceeded - AutoIt will quit to prevent stack overflow ich weiß, dass das ist weil sich die Funktion so oft aufgerufen hat. Ich sehe aber keine Lösung. Könntet ihr mir vielleicht sagen, was an meinem Programm falsch ist? ;TIC TAC TOE; #include<GUIConstantsEx.au3> Global $aSpielfeldbutton Global $Check1 = 0 Global $Check2 = 0
Hilfe, Stack Overflow!
01/29/2014 - AutoIt - 6 Replies
Hallo ich programmiere grade mein ersten bot mit "ImageSearch" und habe das Problem das nach einer weile die Fehlermeldung stack overflow kommt und ich weis nicht wie ich das verhindern soll. Ich arbeite mit autoit seit 2 Wochen und das ist mein Ergebnis. Ich hoffe das ihr mir helfen könnt. Danke. Der autoit code
Voten für Deutsches Stack Overflow
02/14/2013 - Web Development - 2 Replies
Die meisten bzw. viele von euch kennen sicher das Stack Overflow. Es gibt (schon sehr lange) eine möglichkeit zum Voten für ein Deutsches (: Wäre natürlich sehr schick wenn diese in die Beta kommt. Dafür braucht man aber viele Unterstützer. Also Votet (Committen auf der linken seite) (x Stack Overflow (in German) - Area 51 - Stack Exchange
Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.
01/20/2013 - AutoIt - 4 Replies
Hallo Leute, ich hab das folgende Problem mit meinem Bot: Nach ca. 4-5 Std. Laufzeit meines Bots bekomme ich folgende Meldung... "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow." Das ganze an völlig unterschiedlichen Stellen, es ist also wirklich die Addition die das Problem hervorruft und nicht eine bestimmte Funktion etc.
suche rohan atoit script bot
11/07/2009 - Rohan - 26 Replies
suche rohan atoit script kann mir jemand ein script machen zb.attacken soll er und drops aufheben mehr net



All times are GMT +1. The time now is 02:24.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.