Sign in to follow this  
Followers 0
Makaveli10a

This script crashes after 2 houers or so, i dont know why

10 posts in this topic

#1 ·  Posted (edited)

I want to make a loop, where it counts to 72000 with 1 sec delay (20h), does something, counts to 14400 does something else and counts to 72000 again etc.

I made this, it works fine for 60 sec tests, but when it has been running for 2h+- it crashes, any explenation?

#include <Timers.au3>
#include <Misc.au3>


HotKeySet("{F3}", "StartScript")
HotKeySet("{F4}", "StopScript")


$SetLo = 72000 ; 20h
$CounterLOVarb = 0
$SetLi = 14400 ; 4h
$CounterLinVarb = 0
$Sleep = 0

While $Sleep = 0
Sleep ( 1000 )
WEnd


Func StartScript() ; Starter med F1
$Sleep = 1
Sleep ( 2000 )
Start()
EndFunc


Func StopSCript() ; Stop Script med F2
Exit
EndFunc

; |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


Func Start()
If ProcessExists ( "Programm.exe" ) Then ; If running start clean
ProcessClose ( "Programm.exe" )
Sleep ( 2000 )
ProcessClose ( "x.exe" )
Sleep ( 7000 )
Run("Programm.exe", @ScriptDir)
Sleep ( 2000 )
Send ( "{F1}" )
Sleep ( 1000 )
CounterLO()
Else
ProcessClose ( "Programm.exe" )
StartD()
EndIf
EndFunc

Func StartD() ; If nothing is running start all clean
Run("Programm.exe", @ScriptDir)
Sleep ( 2000 )
Send ( "{F1}" )
Sleep ( 1000 )
CounterLO()
EndFunc

Func CounterLO()
$CounterLOVarb += 1
If $CounterLOVarb = $SetLI Then
ProcessClose ( "x.exe" )
Sleep ( 2000 )
ProcessClose ( "Programm.exe" )
Sleep ( 1000 )
$CounterLOVarb = 0
Sleep ( 1000 )
$CounterLIVarb = 0
Sleep ( 10000 )
WaitForL()
Else
LoopLO()
EndIf
EndFunc

Func LoopLO()
Sleep ( 1000 )
ToolTip ( $CounterLOVarb , 1711 , 227 )
CounterLO()
EndFunc


Func WaitForL()
$CounterLinVarb += 1
If $CounterLinVarb = $SetLO Then
Run("Programm.exe", @ScriptDir)
Sleep ( 2000 )
Send ( "{F1}" )
$CounterLOVarb = 0
Sleep ( 1000 )
$CounterLinVarb = 0
Sleep ( 5000 )
CounterLO()
Else
LoopLI()
EndIf
EndFunc

Func LoopLI()
Sleep ( 1000 )
ToolTip ( $CounterLinVarb , 1711 , 227 )
WaitForL()
EndFunc
Edited by Makaveli10a

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Have you ran your script through au3check because you have errors in it?

error: WaitForLogin(): undefined function.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Have you ran your script through au3check because you have errors in it?

Yeah, thats just a paste fail, its not due to that, just change that to "WaitforL()"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

No intention of running it, so what is the error you get or what is happening at that time?

Are you getting a stack overflow as it looks like you keep on calling Func's without ever returning from them?

Edited by Jos
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

No intention of running it, so what is the error you get or what is happening at that time?

Well the error is something in the line of "To many AutoIT programs are running, they have been shut down", Dont hold me up on the exact name of the error, it was something in the line of that, but what is weird, is that it runs fine for 60 sec, when, $SetLo and $SetLi are set to 60, loops and everything, but when i set the values higher, it crashes after some time.

So id say it has something to do with Runtime or the size of the variable?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

See my last comment in previous post and get us some exact information to work with as that makes it soo much easier to help people :)

Edited by Jos
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

See my last comment in previous post and get us some exact information to work with as that makes it soo much easier to help people :)

Yeah, thats proberbly it, so how do i prevent that, and thanks a bunch for the help finding the issue :)

Edited by Makaveli10a

Share this post


Link to post
Share on other sites

Your problem is you're recursing from one function to another and then back to the original function, you can only do that about 1800 times before the script crashes. You need to figure out how to do what you need without functions calling back to their original calling function.

1 person likes this

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 Gude
How 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

Share this post


Link to post
Share on other sites

Your problem is you're recursing from one function to another and then back to the original function, you can only do that about 1800 times before the script crashes. You need to figure out how to do what you need without functions calling back to their original calling function.

I asume i could just set a variable and make a "While" loop, to loop the counter, instead of functions calling back.

Share this post


Link to post
Share on other sites

I asume i could just set a variable and make a "While" loop, to loop the counter, instead of functions calling back.

Yeah i did this, anyhow thanks a bunch for the help guys, probably saved me hours of trying to figure out the issue :-)

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