SirJohann Posted April 22, 2014 Posted April 22, 2014 (edited) Hi guys. I've been working in a conversational adventure with AutoIt, but I have a problem. Is not a big problem, but If you can help me with it, that would be great. This is the code: expandcollapse popup#AutoIt3Wrapper_Run_Before = mkdir build #AutoIt3Wrapper_OutFile = build\ConsoleAdventure.exe #RequireAdmin ;~D #include 'WinAPI.au3' #include 'MsgBoxConstants.au3' ;~D #include 'include\Console.au3' ; Matt Diesel (Mat) #include 'include\AutoItObject.au3' ; monoceres, trancexx, Kip, Prog@ndy (license in docs\AutoItObject) _AutoItObject_Startup() OnAutoItExitRegister('_OnExit') Global $_oErrorHandler = ObjEvent('AutoIt.Error', '_OnObjectError') Global $_oConsole = _NewConsole() If Not $_oConsole.Alloc Then _WinAPI_ShowError('Error allocating the console') ;~D While True Sleep(100) WEnd Func _NewConsole() Local $oClass = _AutoItObject_Class() With $oClass .Create() .AddProperty('Alloc', $ELSCOPE_READONLY, _Console_Alloc()) EndWith Return $oClass.Object EndFunc Func _OnObjectError($oError) _WinAPI_ShowError($oError.windescription & 'Line: ' & $oError.scriptline) EndFunc Func _OnExit() MsgBox($MB_ICONINFORMATION, '_OnExit', True) ;~D _AutoItObject_Shutdown() EndFunc Everything works fine, but _OnExit is never called. I tried with SetConsoleCtrlHandle, in Kernel32.dll, and I'm able to catch and handle the events, but the close event always close the process and _OnExit is never called. Any ideas for a possible solution? Is not a big problem, and shutting down the library is not fully required, but I don't like to leave libraries open. ~Sorry if I wrote something wrong, I'm not english-speaker~ Edit: The ;~D lines are debug lines, they will be deleted. Edited April 22, 2014 by SirJohann Codes codes codes.
jaberwacky Posted April 22, 2014 Posted April 22, 2014 I think you need the Exit keyword somewhere in your code. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
SirJohann Posted April 22, 2014 Author Posted April 22, 2014 Also tried, but anyways, when the console shows up and you close it it's like calling exit, it closes the program with exit code 0, but thanks. Codes codes codes.
jaberwacky Posted April 22, 2014 Posted April 22, 2014 I see, I've never used _WinAPI_ShowError. But anyways, I think the problem lies here: If Not $_oConsole.Alloc Then _WinAPI_ShowError('Error allocating the console') If I remove the line then all seems well with the world. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
SirJohann Posted April 22, 2014 Author Posted April 22, 2014 ¿But is _OnCall called? I'm gonna try. Codes codes codes.
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