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)

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

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
 Share

  • Recently Browsing   0 members

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