Jump to content

Keep a program alive


Recommended Posts

Hi my friends !

Sometimes, I've not find the reason why, my program (a compliled script) stops working (crash) without error... Is there a way to keep it alive with something like this "on error do nothing" (I've time to find the reason before few weeks) ?

Edited by akorx

AkorxMail akorx@yahoo.fr

Link to comment
Share on other sites

Yes, remove the root problem. 

Honestly. Make your program more reliable so you won't need a 'trick' to restart it after a crash. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Not easy to advise without seeing your code. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You can use OnAutoItExitRegister (at the beginning of your code), then you will know if you script ends due to a crash or a logical exit.

Example :

OnAutoItExitRegister("_OnExitFunc")

; You code....

Func _OnExitFunc()
    MsgBox(48, "", "Exiting script...")
EndFunc

With this code, if the MsgBox appears, then if is not due to a crash but a bad scripting... In this case you can use ShellExecute(@ScriptFullPath) in the _OnExitFunc function to relaunch your script (but it would be really better to determine cause of the exit instead)

Edit : as Water said, show your code...

Edited by jguinch
Link to comment
Share on other sites

The function is not called when the script crashes. Check @exitMethod for the supported methods to exit the script.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

First, thanks for yours replies guys !

I haven't got the script here because it's on computer at work... but it has no "exit" because it runs every time, like an antivirus program. Endeed, it's a program to tile windows, fixe others at the top, etc.

I can imagine that the crash of my program appears when I want to resize a window that is not responding (but his process is still there). We can understand behind this, that it's NOT a "normal case". A "normal case" is : the process exists or it doesn't exist, we can verify his state before running the function (resize for example). A zombie process or a process that is not responding is NOT a "normal case". You understand :blink: ?

So I suppose that we can find a function "ON ERROR" that stops the resize function when it happens in order to keep my program alives, but how can we do this with autoit?

PS : sorry for my bad english, I'm french.

Edited by akorx

AkorxMail akorx@yahoo.fr

Link to comment
Share on other sites

Your english is not so bad :)

First, I suggest you to post your code here as soon as you can : I'm pretty sure that someone will point out why you script fails.tI

To find out the issue by yourself, you can add an ouput comment per line (to the console or a log file). If you can reproduce the problem with the non-compiled script, look at the Trace: Add trace line feature on Scite, it should be usefull to find the faulty line.

Il y a plein de français par ici... ^_^

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...