drtrann Posted December 8, 2012 Share Posted December 8, 2012 hey guys, I'm working with a script and it works perfectly fine for about 4 hours, after which to tosses a recursion error. I've looked through the code several times and at no time do i cause an infinite loop, so is there another way that I could cause a recursion error besides calling a function within itself? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 8, 2012 Moderators Share Posted December 8, 2012 Hi, drtrann. And just how are we supposed to help you debug your script without seeing it? Please post what you have and we will do our best to assist. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2012 Developers Share Posted December 8, 2012 (edited) so is there another way that I could cause a recursion error besides calling a function within itself?sure: Func A calls Func B; Func B calls Func C; Func C calls Func A....or any more complex variation.So post your script when you want us to look at the cause.Jos Edited December 8, 2012 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 (edited) its really long so hopefully you dont mind. sorry for the code being kinda messy, rigging things together until they work and dont touch it once its working properly (dont fix what aint broke ) expandcollapse popup#include #include #include "myImageSearch.au3" #include #include #include #include #include #include #include local $sFileName local $catch = 0 local $x local $y local $found local $Error = "0" local $wincount = 0 Global $failcount = 0 Global $timerfail Global $timerstart Global $timerfailninty Global $timerstartninty Global $timerfailten Global $timerstartten Global $timerfailfifteen Global $timerstartfifteen global $locationone global $locationonex global $locationoney global $locationtwo global $locationtwox global $locationtwoy global $locationthree global $locationthreex global $locationthreey global $latency global $start = 0 HotKeySet( "{ESC}", "_exit") HotKeySet( "`", "restart") #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("form finish", 282, 363, 192, 124) $Edit1 = GUICtrlCreateEdit("", 8, 8, 265, 305, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, "form finish 1.5 activated" & @CRLF) $finished = GUICtrlCreateLabel("total finish", 8,344,100,17) $finishnum = GUICtrlCreateLabel($wincount, 65,344, 40,17) $calibrate = GUICtrlCreateButton("calibrate",192,312,83,25) $go = GUICtrlCreateButton("go",192,336,83,25) $fails = GUICtrlCreateLabel("fails", 128,344,22,17) $failnum = GUICtrlCreateLabel($failcount, 150,344,22,17) $formopt = GUICtrlCreateCombo("None", 8, 312, 80, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "90 second|10 minutes|15 minutes") $latency = GUICtrlCreateInput(900, 128, 312, 40, 20) GUISetState(@SW_SHOW) ;GUICtrlSetLimit($Edit1, 0xF423F); = 999,999 #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $go WinSetOnTop($Form1, "", 1) WinActivate("internet explorer") Sleep (2000) $latency = GUICtrlRead($latency) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "starting: E" & $Error & @CRLF, 1) Readsettings() GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "location1: " & $locationonex& " " & $locationoney & @CRLF, 1) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "location2: " & $locationtwox& " " & $locationtwoy & @CRLF, 1) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "location3: " & $locationthreex& " " & $locationthreey & @CRLF, 1) sleep(100) Global $formselect = $formopt formcheck() Case $calibrate ;do calibrate mode WinSetOnTop($Form1, "", 1) WinActivate("internet explorer") Sleep (1000) calibrate() EndSwitch WEnd func _exit() Exit EndFunc Func restart() WinSetOnTop($Form1, "", 1) WinActivate("internet explorer") Sleep (1000) EndFunc Func formcheck() if GUICtrlRead($formselect) == "None" then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "no marker" & @CRLF, 1) start() EndIf if GUICtrlRead($formselect) == "90 second" Then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "90 second marker" & @CRLF, 1) $timerstartninty = TimerInit() nintysec() EndIf if GUICtrlRead($formselect) == "10 minutes" Then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "10 minute marker" & @CRLF, 1) $timerstartten = TimerInit() tenminute() EndIf if GUICtrlRead($formselect) == "15 minutes" Then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "15 minute marker" & @CRLF, 1) $timerstartfifteen = TimerInit() fifteenminute() EndIf EndFunc Func formfailcheck() GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "CHECKING FORM TIMERS" & @CRLF, 1) if GUICtrlRead($formselect) == "15 minutes" Then $timerstartninty = 0 $timerstartten = 0 $timerfailfifteen = TimerDiff($timerstartfifteen) if $timerfailfifteen > 900000 Then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "15 minute" & @CRLF, 1) fifteenminute() EndIf EndIf if GUICtrlRead($formselect) == "10 minutes" Then $timerstartninty = 0 $timerfailten = TimerDiff($timerstartten) $timerfailfifteen = 0 if $timerfailten > 600000 Then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "10 minute" & @CRLF, 1) tenminute() EndIf EndIf if GUICtrlRead($formselect) == "None" then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "no marker" & @CRLF, 1) start() EndIf if GUICtrlRead($formselect) == "90 second" Then $timerfailninty = TimerDiff($timerstartninty) $timerfailten = 0 $timerfailfifteen = 0 if $timerfailninty > 90000 Then GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "90 SEC" & @CRLF, 1) nintysec() EndIf EndIf GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "time not up, restarting" & @CRLF, 1) EndFunc Func nintysec() Send(2) sleep (10) MouseMove($locationthreex,$locationthreey,1) sleep (10) MouseClick("Left") sleep (4000) start() EndFunc Func tenminute() sleep (200) Send(3) sleep (10) MouseMove($locationthreex,$locationthreey,1) sleep (10) MouseClick("Left") sleep (4000) $timerstartninty = 0 $timerstartfifteen = 0 start() EndFunc Func fifteenminute() sleep (200) Send(4) sleep (10) MouseMove($locationthreex,$locationthreey,1) sleep (10) MouseClick("Left") sleep (4000) $timerstartninty = 0 $timerstartten = 0 start() EndFunc func failcheck() ;lets see if we missed something. if we've been sitting for to long, restart the script if $timerfail> 25000 Then MouseClick("Left") $timerstart = TimerInit() GUICtrlSetData($Edit1, @CRLF & "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & " failed after " & $timerfail & @CRLF, 1) $failcount = $failcount + 1 GUICtrlSetData($failnum, $failcount) $timerfail = 0 start() EndIf EndFunc func Start() $timerstart = TimerInit() sleep(200) MouseMove($locationonex, $locationoney, 1) sleep(100) Send (1) sleep (100) MouseClick("Left") GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "starting form: E" & $Error & @CRLF, 1) sleep(100) MouseMove($locationtwox,$locationtwoy, 1) GUICtrlSetData($Edit1,"[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "moving to resting position: E" & $Error & @CRLF, 1) formcomplete() EndFunc Func formcomplete() GUICtrlSetData($Edit1,"[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "checking form: E" & $Error & @CRLF, 1) do formscan() Until $Error = 0 $timerstart = TimerInit() sleep(800) MouseClick("Left") sleep($latency) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "looking for pisition 2: E" & $Error & @CRLF, 1) completecheck() FileDelete(@ScriptDir & "completecheck.BMP") if $Error = 0 Then $timerstart = TimerInit() completefound() EndIf If $Error = 3 Then GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "not complete checking again: E" & $Error & @CRLF, 1) do formscan() Until $Error = 0 $timerstart = TimerInit() sleep(800) MouseClick("Left") sleep($latency) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "looking for pisition 2: E" & $Error & @CRLF, 1) completecheck() FileDelete(@ScriptDir & "completecheck.BMP") If $Error = 0 Then ;somethings on the line again, doing second pull $timerstart = TimerInit() GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "not complete checking again: E" & $Error & @CRLF, 1) completefound() EndIf If $Error = 3 Then ;bastard got away again, looking for the 3rd pull do formscan() Until $Error =0 ;we got this bastard now, look for that loot window and lets reboot this bitch. $timerstart = TimerInit() sleep(800) MouseClick("Left") sleep($latency) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "looking for pisition 2: E" & $Error & @CRLF, 1) completecheck() FileDelete(@ScriptDir & "completecheck.BMP") If $Error = 0 Then $timerstart = TimerInit() GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "success on attempt 3: E" & $Error & @CRLF, 1) completefound() EndIf EndIf EndIf EndFunc func completecheck() failcheck() $Error = 4 _ScreenCapture_Capture(@scriptdir & "pos3check.bmp", $locationtwox-3,$locationtwoy-3,$locationtwox+33, $locationtwoy+23, True) sleep(10) myImageSearch_Picture(@ScriptDir & "pos3check.bmp",@ScriptDir & "success.bmp",0,0,36,26,"") $Error=@error $timerfail = TimerDiff($timerstart) EndFunc func formscan() failcheck() _ScreenCapture_Capture(@ScriptDir & "completecheck.BMP", $locationtwox-3,$locationtwoy-3,$locationtwox+18, $locationtwoy+9, True) myImageSearch_Picture(@ScriptDir & "completecheck.BMP",@ScriptDir & "compete.BMP",0,0,21,11,"") $Error=@error sleep (10) $timerfail = TimerDiff($timerstart) EndFunc Func completefound() failcheck() sleep(200) MouseMove($locationtwox+10 ,$locationtwoy, 1) MouseClick("Left") sleep(10) GUICtrlSetData($Edit1, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "found complete, restarting: E" & $Error &@CRLF, 1) $wincount = $wincount +1 GUICtrlSetData($finishnum, $wincount) formfailcheck() EndFunc Func calibrate() ;capture settings and write them to settings.txt FileDelete("settings.txt") GUICtrlSetData($Edit1, "click position 1" & @CRLF, 1) Do Sleep(10) Until _IsPressed(01) $locationone = MouseGetPos() GUICtrlSetData($Edit1, "pos 1 location set to: " & $locationone[0] & " " & $locationone[1] & @CRLF, 1) sleep (800) GUICtrlSetData($Edit1, "click position 2" & @CRLF, 1) Do Sleep(10) until _IsPressed(01) $locationtwo = MouseGetPos() GUICtrlSetData($Edit1, "pos 2 location set to: " & $locationtwo[0] & " " & $locationtwo[1] & @CRLF, 1) sleep(800) GUICtrlSetData($Edit1, "click position 3" & @CRLF, 1) Do Sleep(10) until _IsPressed(01) $locationthree = MouseGetPos() GUICtrlSetData($Edit1, "pos 3 location set to: " & $locationthree[0] & " " & $locationthree[1] & @CRLF, 1) sleep (800) GUICtrlSetData($Edit1, "form complete calibrated to your screen! click go!" & @CRLF, 1) sleep(10) ;write setttings to settings.txt FileWrite("settings.txt",$locationone[0]& @CRLF) FileWrite("settings.txt",$locationone[1]& @CRLF) FileWrite("settings.txt",$locationtwo[0]& @CRLF) FileWrite("settings.txt",$locationtwo[1]& @CRLF) FileWrite("settings.txt",$locationthree[0]& @CRLF) FileWrite("settings.txt",$locationthree[1]& @CRLF) EndFunc func Readsettings() ;reads settings from settings.txt $settings = FileOpen("settings.txt") $locationonex = FileReadLine($settings, 1) $locationoney = FileReadLine($settings, 2) $locationtwox = FileReadLine($settings, 3) $locationtwoy = FileReadLine($settings, 4) $locationthreex = FileReadLine($settings, 5) $locationthreey = FileReadLine($settings, 6) EndFunc Edited December 8, 2012 by drtrann Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 sure: Func A calls Func B; Func B calls Func C; Func C calls Func A....or any more complex variation.So post your script when you want us to look at the cause.Josthis could be my issue. what way do i have of avoiding it assuming i have a task that needs to be repeated until stopped? Link to comment Share on other sites More sharing options...
Developers Jos Posted December 8, 2012 Developers Share Posted December 8, 2012 I do not see the relation of recursion and repeat. A For...Next or While...Wend loops will repeat until a certain condition is met. Recursion is a totally different animal. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 (edited) well after about 450-490 completes of the script, it returns with a recursion error saying that its closed the program to stop a stack overflow, takes about 3-4 hours though to hit that point edit: after looking at that code i posted. it looks like your website added "amp ;" after every &. thats not part of my code, it showed up after i saved the post Edited December 8, 2012 by drtrann Link to comment Share on other sites More sharing options...
Bowmore Posted December 8, 2012 Share Posted December 8, 2012 I have spotted one recursion that can occur in your script under certain conditions. Start() calls formcomplete() which calls completecheck() which calls failcheck() which then calls start() without ever exiting start. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 I do not see the relation of recursion and repeat. A For...Next or While...Wend loops will repeat until a certain condition is met.Recursion is a totally different animal.so your saying if I just put the start() and formcomplete() in a while loop it should stop the error? Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 I have spotted one recursion that can occur in your script under certain conditions.Start() calls formcomplete() which calls completecheck() which calls failcheck() which then calls start() without ever exiting start.not sound like i want you to do it for me, but how would i go about fixing this while maintaining the function of the code? Link to comment Share on other sites More sharing options...
Bowmore Posted December 8, 2012 Share Posted December 8, 2012 What you need to do is instead of calling Start() directly when there is a problem you need to set @error and return to the previous function until you get back to start. I've made a few changes to your script as an example of how to do this (look for ;<== added this). You may also need to make similar changes elsewhere in your script. expandcollapse popup#include #include #include "myImageSearch.au3" #include #include #include #include #include #include #include Local $sFileName Local $catch = 0 Local $x Local $y Local $found Local $Error = "0" Local $wincount = 0 Global $failcount = 0 Global $timerfail Global $timerstart Global $timerfailninty Global $timerstartninty Global $timerfailten Global $timerstartten Global $timerfailfifteen Global $timerstartfifteen Global $locationone Global $locationonex Global $locationoney Global $locationtwo Global $locationtwox Global $locationtwoy Global $locationthree Global $locationthreex Global $locationthreey Global $latency Global $start = 0 HotKeySet("{ESC}", "_exit") HotKeySet("`", "restart") #include #include #include #region ### START Koda GUI section ### Form= $Form1 = GUICreate("form finish", 282, 363, 192, 124) $Edit1 = GUICtrlCreateEdit("", 8, 8, 265, 305, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetData(-1, "form finish 1.5 activated" & amp; @CRLF) $finished = GUICtrlCreateLabel("total finish", 8, 344, 100, 17) $finishnum = GUICtrlCreateLabel($wincount, 65, 344, 40, 17) $calibrate = GUICtrlCreateButton("calibrate", 192, 312, 83, 25) $go = GUICtrlCreateButton("go", 192, 336, 83, 25) $fails = GUICtrlCreateLabel("fails", 128, 344, 22, 17) $failnum = GUICtrlCreateLabel($failcount, 150, 344, 22, 17) $formopt = GUICtrlCreateCombo("None", 8, 312, 80, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "90 second|10 minutes|15 minutes") $latency = GUICtrlCreateInput(900, 128, 312, 40, 20) GUISetState(@SW_SHOW) ;GUICtrlSetLimit($Edit1, 0xF423F); = 999,999 #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $go WinSetOnTop($Form1, "", 1) WinActivate("internet explorer") Sleep(2000) $latency = GUICtrlRead($latency) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "starting: E" & $Error & @CRLF, 1) Readsettings() GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "location1: " & $locationonex& " " & $locationoney & @CRLF, 1) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "location2: " & $locationtwox& " " & $locationtwoy & @CRLF, 1) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "location3: " & $locationthreex& " " & $locationthreey & @CRLF, 1) Sleep(100) Global $formselect = $formopt formcheck() Case $calibrate ;do calibrate mode WinSetOnTop($Form1, "", 1) WinActivate("internet explorer") Sleep(1000) calibrate() EndSwitch WEnd Func _exit() Exit EndFunc ;==>_exit Func restart() WinSetOnTop($Form1, "", 1) WinActivate("internet explorer") Sleep(1000) EndFunc ;==>restart Func formcheck() ;finds out what lure to use and directs the program which lure to use. If GUICtrlRead($formselect) == "None" Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "no marker" & @CRLF, 1) start() EndIf If GUICtrlRead($formselect) == "90 second" Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "90 second marker" & @CRLF, 1) $timerstartninty = TimerInit() nintysec() EndIf If GUICtrlRead($formselect) == "10 minutes" Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "10 minute marker" & @CRLF, 1) $timerstartten = TimerInit() tenminute() EndIf If GUICtrlRead($formselect) == "15 minutes" Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "15 minute marker" & @CRLF, 1) $timerstartfifteen = TimerInit() fifteenminute() EndIf EndFunc ;==>formcheck Func formfailcheck() ;lets check how long the lure is on there, if its expired, reapply the lure GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "CHECKING FORM TIMERS" & @CRLF, 1) If GUICtrlRead($formselect) == "15 minutes" Then $timerstartninty = 0 $timerstartten = 0 $timerfailfifteen = TimerDiff($timerstartfifteen) If $timerfailfifteen > 900000 Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "15 minute" & @CRLF, 1) fifteenminute() EndIf EndIf If GUICtrlRead($formselect) == "10 minutes" Then $timerstartninty = 0 $timerfailten = TimerDiff($timerstartten) $timerfailfifteen = 0 If $timerfailten > 600000 Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "10 minute" & @CRLF, 1) tenminute() EndIf EndIf If GUICtrlRead($formselect) == "None" Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "no marker" & @CRLF, 1) return SetError(1,0,-1);<==== Added this ; start();<==== Commented out this EndIf If GUICtrlRead($formselect) == "90 second" Then $timerfailninty = TimerDiff($timerstartninty) $timerfailten = 0 $timerfailfifteen = 0 If $timerfailninty > 90000 Then GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "90 SEC" & @CRLF, 1) nintysec() EndIf EndIf GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & "time not up, restarting" & @CRLF, 1) EndFunc ;==>formfailcheck Func nintysec() Send(2) Sleep(10) MouseMove($locationthreex, $locationthreey, 1) Sleep(10) MouseClick("Left") Sleep(4000) start() EndFunc ;==>nintysec Func tenminute() Sleep(200) Send(3) Sleep(10) MouseMove($locationthreex, $locationthreey, 1) Sleep(10) MouseClick("Left") Sleep(4000) $timerstartninty = 0 $timerstartfifteen = 0 start() EndFunc ;==>tenminute Func fifteenminute() Sleep(200) Send(4) Sleep(10) MouseMove($locationthreex, $locationthreey, 1) Sleep(10) MouseClick("Left") Sleep(4000) $timerstartninty = 0 $timerstartten = 0 start() EndFunc ;==>fifteenminute Func failcheck() ;lets see if we missed something. if we've been sitting for to long, restart the script If $timerfail > 25000 Then MouseClick("Left") $timerstart = TimerInit() GUICtrlSetData($Edit1, @CRLF & amp; "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & " failed after " & $timerfail & @CRLF, 1) $failcount = $failcount + 1 GUICtrlSetData($failnum, $failcount) $timerfail = 0 start() EndIf EndFunc ;==>failcheck Func Start() Local $iTryAgain = True;<==== Added this while $iTryAgain;<==== Added this $timerstart = TimerInit() Sleep(200) MouseMove($locationonex, $locationoney, 1) Sleep(100) Send(1) Sleep(100) MouseClick("Left") GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "starting form: E" & $Error & @CRLF, 1) Sleep(100) MouseMove($locationtwox, $locationtwoy, 1) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "moving to resting position: E" & $Error & @CRLF, 1) formcomplete() if @error Then ;<==== Added this $iTryAgain = True;<==== Added this Else;<==== Added this $iTryAgain = False;<==== Added this endif;<==== Added this WEnd;<==== Added this EndFunc ;==>Start Func formcomplete() GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "checking form: E" & $Error & @CRLF, 1) Do formscan() Until $Error = 0 $timerstart = TimerInit() Sleep(800) MouseClick("Left") Sleep($latency) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "looking for pisition 2: E" & $Error & @CRLF, 1) completecheck() FileDelete(@ScriptDir & amp; "completecheck.BMP") If $Error = 0 Then $timerstart = TimerInit() completefound() if @error Then Returrn SetError(1,0,-1);<==== Added this EndIf If $Error = 3 Then GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "not complete checking again: E" & $Error & @CRLF, 1) Do formscan() Until $Error = 0 $timerstart = TimerInit() Sleep(800) MouseClick("Left") Sleep($latency) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "looking for pisition 2: E" & $Error & @CRLF, 1) completecheck() FileDelete(@ScriptDir & amp; "completecheck.BMP") If $Error = 0 Then ;somethings on the line again, doing second pull $timerstart = TimerInit() GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "not complete checking again: E" & $Error & @CRLF, 1) completefound() if @error Then Returrn SetError(2,0,-1);<==== Added this EndIf If $Error = 3 Then ;bastard got away again, looking for the 3rd pull Do formscan() Until $Error = 0 ;we got this bastard now, look for that loot window and lets reboot this bitch. $timerstart = TimerInit() Sleep(800) MouseClick("Left") Sleep($latency) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "looking for pisition 2: E" & $Error & @CRLF, 1) completecheck() FileDelete(@ScriptDir & amp; "completecheck.BMP") If $Error = 0 Then $timerstart = TimerInit() GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "success on attempt 3: E" & $Error & @CRLF, 1) completefound() if @error Then Returrn SetError(3,0,-1);<==== Added this EndIf EndIf EndIf EndFunc ;==>formcomplete Func completecheck() failcheck() $Error = 4 _ScreenCapture_Capture(@ScriptDir & amp; "pos3check.bmp", $locationtwox-3,$locationtwoy-3,$locationtwox+33, $locationtwoy+23, True) Sleep(10) myImageSearch_Picture(@ScriptDir & amp; "pos3check.bmp",@ScriptDir & "success.bmp",0,0,36,26,"") $Error = @error $timerfail = TimerDiff($timerstart) EndFunc ;==>completecheck Func formscan() failcheck() _ScreenCapture_Capture(@ScriptDir & amp; "completecheck.BMP", $locationtwox-3,$locationtwoy-3,$locationtwox+18, $locationtwoy+9, True) myImageSearch_Picture(@ScriptDir & amp; "completecheck.BMP",@ScriptDir & "compete.BMP",0,0,21,11,"") $Error = @error Sleep(10) $timerfail = TimerDiff($timerstart) EndFunc ;==>formscan Func completefound() failcheck() Sleep(200) MouseMove($locationtwox + 10, $locationtwoy, 1) MouseClick("Left") Sleep(10) GUICtrlSetData($Edit1, "[" & amp; @HOUR & ":" & @MIN & ":" & @SEC & "] " & "found complete, restarting: E" & $Error &@CRLF, 1) $wincount = $wincount + 1 GUICtrlSetData($finishnum, $wincount) formfailcheck() if @error Then Return SetError(1,0,-1) ;<==== Added this EndFunc ;==>completefound Func calibrate() ;capture settings and write them to settings.txt FileDelete("settings.txt") GUICtrlSetData($Edit1, "click position 1" & amp; @CRLF, 1) Do Sleep(10) Until _IsPressed(01) $locationone = MouseGetPos() GUICtrlSetData($Edit1, "pos 1 location set to: " & amp; $locationone[0] & " " & $locationone[1] & @CRLF, 1) Sleep(800) GUICtrlSetData($Edit1, "click position 2" & amp; @CRLF, 1) Do Sleep(10) Until _IsPressed(01) $locationtwo = MouseGetPos() GUICtrlSetData($Edit1, "pos 2 location set to: " & amp; $locationtwo[0] & " " & $locationtwo[1] & @CRLF, 1) Sleep(800) GUICtrlSetData($Edit1, "click position 3" & amp; @CRLF, 1) Do Sleep(10) Until _IsPressed(01) $locationthree = MouseGetPos() GUICtrlSetData($Edit1, "pos 3 location set to: " & amp; $locationthree[0] & " " & $locationthree[1] & @CRLF, 1) Sleep(800) GUICtrlSetData($Edit1, "form complete calibrated to your screen! click go!" & amp; @CRLF, 1) Sleep(10) ;write setttings to settings.txt FileWrite("settings.txt", $locationone[0] & amp; @CRLF) FileWrite("settings.txt", $locationone[1] & amp; @CRLF) FileWrite("settings.txt", $locationtwo[0] & amp; @CRLF) FileWrite("settings.txt", $locationtwo[1] & amp; @CRLF) FileWrite("settings.txt", $locationthree[0] & amp; @CRLF) FileWrite("settings.txt", $locationthree[1] & amp; @CRLF) EndFunc ;==>calibrate Func Readsettings() ;reads settings from settings.txt $settings = FileOpen("settings.txt") $locationonex = FileReadLine($settings, 1) $locationoney = FileReadLine($settings, 2) $locationtwox = FileReadLine($settings, 3) $locationtwoy = FileReadLine($settings, 4) $locationthreex = FileReadLine($settings, 5) $locationthreey = FileReadLine($settings, 6) EndFunc ;==>Readsettings "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 thank you very much for the pointers. so just so i am understanding this fully. in the future i should always put a while loop inside my "main" function to make it continually repeat doing the start() function. instead of calling start() i instead call return SetError(1,0,-1) which is effectively restarts start() (right?) Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 8, 2012 Share Posted December 8, 2012 (edited) Not quite. SetError(1,0,-1) Is all you need as SetError() will Return on its own. Review the SetError() function in the help file. Edited December 8, 2012 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
drtrann Posted December 8, 2012 Author Share Posted December 8, 2012 (edited) Not quite. SetError(1,0,-1) Is all you need as SetError() will Return on its own. Review the SetError() function in the help file. alright thanks *edit: so after making the changes above to my code, stops after it finishes the first completion, and just sits there. based on the log it looks like after going to formfailcheck() then reading "none", returning the error and then just doing nothing. again im a little hazy on how this actually works so would appreciate some input on how to make it go back to start() at this point edit also wouldnt this cause issues with the fact that i am already using @error elsewhere in my script? Edited December 8, 2012 by drtrann Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 9, 2012 Share Posted December 9, 2012 (edited) The value of @error is destroyed reset when any other function returns ANYTHING. That's why you check it IMMEDIATELY after the function you want to check the @error status of. So ... no. Using @error elsewhere means nothing to any custom SetError() or any other @error check for that matter.. Edited December 9, 2012 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
drtrann Posted December 9, 2012 Author Share Posted December 9, 2012 so i've made all the changes above and the script appears to stop once it passes formfailcheck() and it never returns to start(). am i missing something? Link to comment Share on other sites More sharing options...
BrewManNH Posted December 9, 2012 Share Posted December 9, 2012 How are we supposed to answer that if we don't know what you've changed and what your script looks like now? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
drtrann Posted December 9, 2012 Author Share Posted December 9, 2012 How are we supposed to answer that if we don't know what you've changed and what your script looks like now?well it was basically what was posted above, but i changed what he put and it works now. i assume he mistook what the functions did by their names, he had them stopping at the functions that should return true, removed it, and everything works perfectly. thanks again for the help guys, i appreciate it Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now