Jump to content

Exit(0) doesn't terminate script


c.haslam
 Share

Recommended Posts

I have written a script that is several thousand lines, accesses functions in several DLLs, uses RichEdit, etc. It uses message-loops for several windows. It works as expected except ...

Problem: When I close the main window, the window disappears and the AutoIt icon disappears from the System Tray, but the script continues to run. I know that it executes Exit(0) because I traced this line. Does anyone have any idea why the script continues to run? That iy is still running is shown by SciTE | Tools: Stop Executing is available, and works. Also Task Manager shows that AutoIt3.exe is still running.

OK. I know the standard advice: simplify the script, and submit the result for a guru to examine. But, in this case, that's easier said than done!

Is there a subtle bug in AutoIt? What could cause AutoIt to continue to run without an icon showing in the System Tray?

Any and all suggestions are most welcome.

...chris

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

0 is the default anyway. What happens when you just use Exit with no error code?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I tried Exit on its own. Same result. Thanks for asking.

Do you handle WM_CLOSE somewhere? (I know this can cause your symptoms)

Have you registered an exit function?

Have you ensured that all the dll's which were opened have been closed? (I don't think this would cause your symptoms but maybe.)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Do you handle WM_CLOSE somewhere? (I know this can cause your symptoms)

Have you registered an exit function?

Have you ensured that all the dll's which were opened have been closed? (I don't think this would cause your symptoms but maybe.)

I remember having this problem in a large script and never did find the answer. I assumed it was just something in my code but it went away after the script was compiled so I didn't look any further.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Is your script all in one file? Maybe one exits, but another is still running..

The script is in multiple files. The main file #includes the others. Only the main script is run.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

Do you handle WM_CLOSE somewhere? (I know this can cause your symptoms)

Have you registered an exit function?

Have you ensured that all the dll's which were opened have been closed? (I don't think this would cause your symptoms but maybe.)

A snippet:

While 1 
$nMsg = GUIGetMsg() 
 If $nMsg > 0 Then 
CopyEditBoxesContentsToDataAr() 
EndIf 
If Not OpenViaMRU($nMsg) Then 
Switch $nMsg 
Case $GUI_EVENT_CLOSE, $mnuProjExit 
If FinishUp() Then Exit(0) 
 EndIf

Sorry for the bad formatting. Don't remember how to make the listing tidy in a post.

There is an OnAutoItExit() function.

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

  • Moderators

A snippet:

While 1 
$nMsg = GUIGetMsg() 
 If $nMsg > 0 Then 
CopyEditBoxesContentsToDataAr() 
EndIf 
If Not OpenViaMRU($nMsg) Then 
Switch $nMsg 
Case $GUI_EVENT_CLOSE, $mnuProjExit 
If FinishUp() Then Exit(0) 
 EndIf

Sorry for the bad formatting. Don't remember how to make the listing tidy in a post.

There is an OnAutoItExit() function.

You're obviously catching the exit and doing something somewhere in the code.

Anything that anyone tells you will be pure speculation.

It's advised that you create a reproducer that demonstrates the issue if you really want an answer that would help, rather than having everyone chase their tails.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I remember having this problem in a large script and never did find the answer. I assumed it was just something in my code but it went away after the script was compiled so I didn't look any further.

I tried compiling the code. I then ran the resulting .exe. It exited normally.

So it looks like a bug in autoit3.exe or a bug in my code that isn't being caught by the syntax checker, etc. Should this be reported as a bug in AutoIt?

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

I tried compiling the code. I then ran the resulting .exe. It exited normally.

So it looks like a bug in autoit3.exe or a bug in my code that isn't being caught by the syntax checker, etc. Should this be reported as a bug in AutoIt?

Thats the same experience I had. As to whether it's a bug or not, it's an anomally someplace but I'm not sure where. Like I said it happens rarely.

What happens if you run it without using Scite? Just right-click the script and choose Run Script. It seems to me that with that one script it only happened if I ran it in Scite but I can't be sure because I seldom used Scite back then and even when I did, I usually just used it as a simple editor without the tools.

EDIT: I should also point out the following.

In order to report a bug you have to know where the bug is. AutoIt? Scite?

To report a bug you need a repro script and if there is nothing wrong in your code then that will be difficult to do at best.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • Developers

As Smoke_N already said: Post a reproducing script here that we also can run to show us the problem.

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

As Smoke_N already said: Post a reproducing script here that we also can run to show us the problem.

Jos

To add to what Jos and SmOke_N have been saying, you haven't explained why you think Exit(0) isn't working. How did you decide that FinishUp() returned true, or that your exit function didn't start?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I accept that, to figure out whether the problem is in my code or in AutoIt, I need to do a lot more checking of my code. I will try to do this over the next few weeks. My approach will be to try earlier versions of the script, to see in which version the trouble began. I was hoping that someone could tell me how the AutoIt icon could disappear from the System Tray and AutoIt3.exe still be running.

I do know that execution continues even when the script is not run from SciTe.

Being an author of GuiRichEdit, I do wonder whether the fault lies in this UDF, perhaps when there are multiple RichEdit controls in a window. Does my Finishup() need to "destroy" each of these controls?

Thanks for the help. I love AutoIt!

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

This bug is already known. #1319

You have to add _GUICtrlRichEdit_Destroy on exit (OnAutoItExitRegister)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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...