Jump to content

[Help] Conversational adventure

Recommended Posts

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)



Global $_oErrorHandler = ObjEvent('AutoIt.Error', '_OnObjectError')

Global $_oConsole = _NewConsole()
If Not $_oConsole.Alloc Then _WinAPI_ShowError('Error allocating the console') ;~D

While True

Func _NewConsole()
    Local $oClass = _AutoItObject_Class()
    With $oClass
        .AddProperty('Alloc', $ELSCOPE_READONLY, _Console_Alloc())
    Return $oClass.Object

Func _OnObjectError($oError)
    _WinAPI_ShowError($oError.windescription & 'Line: ' & $oError.scriptline)

Func _OnExit()
    MsgBox($MB_ICONINFORMATION, '_OnExit', True) ;~D

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~


The ;~D lines are debug lines, they will be deleted.

Edited by SirJohann

Codes codes codes.

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

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

  • Recently Browsing   0 members

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