Sign in to follow this  
Followers 0
SirJohann

[Help] Conversational adventure

5 posts in this topic

#1 ·  Posted (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:

#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 by SirJohann

Codes codes codes.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

¿But is _OnCall called? I'm gonna try.


Codes codes codes.

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