i have a script that works very nicely but recursion ocures very often because of the internal loop
can anyone rewrite this code so recursion wont apear and basicly will do the same thing??
Code:
HotKeySet("{F10}", "first")
While 1
Sleep(100)
WEnd
Func first()
Send("{SPACE}")
While 1
$pix = PixelSearch(429, 552, 431, 554, 0x548E04, 10)
If Not @error Then
Send("{SPACE DOWN}")
Call("second")
EndIf
WEnd
EndFunc ;==>first
Func second()
While 1
$pix2 = PixelSearch(506, 552, 508, 554, 0x709F05, 10)
If Not @error Then
Send("{SPACE UP}")
Call("third")
EndIf
WEnd
EndFunc ;==>second
Func third()
While 1
$pix3 = PixelSearch(424, 552, 426, 554, 0x5B4321, 10)
If Not @error Then
Send("{SPACE DOWN}")
Call("second")
EndIf
WEnd
EndFunc ;==>third
because i dont know amost anithing about autoit,a guy made me this script what works like a charm,only overbuffers the dataflow because of the internal loop after 30 minutes ore so of using it
KDeluxe dein Script würde nicht funktioniert.
Da du $arr als 2 Dimensionale Array deklariert hast.
Aber sie als 1 Dimensionale nutzt.
1. das, 2. selbst wenn es gehen sollte, spricht er das 4. Element eines 2D-Arrays an was nicht existiert.
Außerdem heißt es doch nicht "dein Script würde nicht funktioniert."
Was war denn da los?
das einzige was er vergessen hat, ist den index mit zu nutzen...
korrekt würde es so aussehen:
Code:
Dim $arr[3][6] = [ [429, 552, 431, 554, 0x548E04, "{SPACE DOWN}"], _
[506, 552, 508, 554, 0x709F05, "{SPACE UP}"], _
[424, 552, 426, 554, 0x5B4321, "{SPACE DOWN}"]]
Dim $i = 0, $run = False
HotKeySet("{F10}", "_TogglePause")
Func _TogglePause()
$run = Not $run
If $run Then
$i = 0
Send("{SPACE}")
EndIf
EndFunc
While Sleep(100)
While $run
If $i > 2 Then $i = 1
PixelSearch($arr[$i][0], $arr[$i][1], $arr[$i][2], $arr[$i][3], $arr[$i][4], 10)
If Not @error Then
Send($arr[$i][5])
$i += 1
EndIf
WEnd
WEnd
der größte nachteil an diesem script ist allerdings die verschachtelung der while schleifen. ab der inneren schleife gibt es hier keine cpu entlastung mehr. eine einfache abfrage der $run variable in der hauptschleife wäre hier sinnvoller.
Edit:
fraglich ist auch, ob es hier tatsächlich sinn macht ein array zu nutzen. eventuell sollte man lieber auf eine einfache funktion zur abarbeitung umsteigen...
etwa so:
Code:
HotKeySet("{F10}", "Pause")
Global $globalState=0, $globalRun=False
While Sleep(1)
Action(0, 429, 552, 431, 554, 0x548E04, "{SPACE DOWN}")
Action(1, 506, 552, 508, 554, 0x709F05, "{SPACE UP}")
Action(2, 424, 552, 426, 554, 0x5B4321, "{SPACE DOWN}")
If $globalState >= 2 Then $globalState = 1
WEnd
Func Pause()
$globalRun = Not $globalRun
EndFunc
Func Action($state, $left, $top, $right, $bottom, $color, $send)
If $state=$globalState and $globalRun Then
PixelSearch($left, $top, $right, $bottom, $color, 10)
If not @error Then
Send($send)
$globalState+=1
EndIf
EndIf
EndFunc
so wäre es unter anderem möglich in jedem zustand beliebig viele aktionen durchzuführen.
Mein einziger Fehler besteht allerdings nur darin, dass ich vergessen habe, die 1. Dimension anzugeben. Das kann schon mal passieren, zumal ich die Scripte selbst nicht teste. Als sinnvoll habe ich meine Lösung nie betrachtet, es war spontan das erste was mir eingefallen ist um nur "eine" Anweisung zu verwenden. Rückblickend verstehe ich aber selbst nicht, weshalb ich eine zweite While-Schleife verwendet habe, eigentlich sollte das eine einfache If-Abfrage sein.
Möchte man alles aus dem Script von piku verwenden sollte die Pause() Funktion allerdings so aussehen:
Code:
Func Pause()
$globalRun = Not $globalRun
If $globalRun Then Send("{SPACE}")
EndFunc
Aktuell wird das initiale Send() der first() Funktion nicht beachtet. Bei mir habe ich den Index/Status zusätzlich noch zurückgesetzt. Inwiefern das bei einer "Pause" Funktion tatsächlich sinnvoll ist lässt sich genau sagen.
Bei mir habe ich den Index/Status zusätzlich noch zurückgesetzt. Inwiefern das bei einer "Pause" Funktion tatsächlich sinnvoll ist lässt sich genau sagen.
richtig, das wäre dann wohl eher ein reset, als eine pause :P
wie dem auch sei, ohne eine genaue projektbeschreibung kann hier ohnehin nur gemutmaßt werden, was der TE tatsächlich will.
Several Questions - Recursion/GUI 09/10/2013 - AutoIt - 3 Replies Hey guys, been a while since I've posted in this section.
So I've got several questions I need help with:
I've encountered the dreaded recursion error in one of my more recent scripts.
I've almost completely avoided using a GUI since I started using Autoit. Now that I want to use it I need some help with setting it up. I have several questions for this.
Recursion:
This error has caused me a headache. I've spent time googling this issue and the reason always given is: "You're making a...
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.
How to avoid ban 10/28/2011 - 4Story - 1 Replies Hi as you know buying gold is ilegal and if they faoun out that you did they ban you so i was wondering is there any way to avoid GMS and GA to find out that you buy gold?
[Tut] How to Avoid GM 04/07/2010 - Grand Chase Hacks, Bots, Cheats & Exploits - 15 Replies i have a great methode to Avoid GM's
but it require to know all GM name
NAGC GM LIST:
GM_Bawkzie
GM_Chaos
GM_Grimm
[Tut] How to Avoid GM 04/06/2010 - Grand Chase - 0 Replies i have a great methode to Avoid GM's
but it require to know all GM name
Here are name of GM i know so far( written exacly like in-game):
.GM_Syn
.
.
.
plz post if you know more GM name