Jump to content

Recommended Posts

Posted

I've been using the DebugSetup for log screens but everytime the script is done it leaves the script still running even though i do an exit.

How do you make the script close using the Debug Screens?

Thanks,

p

  • Moderators
Posted

Patchworks,

From looking at the code of Debug.au3, the script remain active until the report window is closed, So as you know the title of the Debug window, just close it when you exit: :)

#include <Debug.au3>

$sTitle = "My Debug Report"

_DebugSetup($sTitle)

For $i = 1 To 9
    _DebugOut("Debug " & $i)
    Sleep(1000)
Next

MsgBox(0, "Ready to Exit?", "Press OK when ready to Exit")

WinClose($sTitle)

I believe you will have to do something like this for every exit option in your script - using OnAutoItExitRegister to close the GUI will not work as the Debug part of the script is still active until you close the Debug GUI = Catch 22. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • 2 years later...
  • 3 months later...
Posted
  On 8/17/2011 at 7:03 AM, Melba23 said:

I believe you will have to do something like this for every exit option in your script - using OnAutoItExitRegister to close the GUI will not work as the Debug part of the script is still active until you close the Debug GUI = Catch 22. :mellow:

Hi Melba23,

I have found a solution. It is not best, because it use AdlibRegister.

But it works fine.  :)

#include <Debug.au3>
_DebugSetup()
AdlibRegister("Debug_ReportWindowWaitClose")
For $i = 1 To 100
    _DebugReport($i)
    Sleep(100)
Next

Func Debug_ReportWindowWaitClose()
    If Not $__gbReportWindowWaitClose_Debug Then Return 0 ; use of the already opened window so no need to wait
    Local $nOld = Opt("WinDetectHiddenText", True)
    Local $hWndReportWindow = WinGetHandle($__gsReportTitle_Debug, $__gsReportWindowText_Debug)
    Opt("WinDetectHiddenText", $nOld)

    $nOld = Opt('GUIOnEventMode', 0) ; save event mode in case user script was using event mode
    Local Const $GUI_EVENT_CLOSE = -3
    Local $aMsg
    While WinExists(HWnd($hWndReportWindow))
        $aMsg = GUIGetMsg(1)
        If Not $aMsg[0] Then ExitLoop
        If $aMsg[1] = $hWndReportWindow And $aMsg[0] = $GUI_EVENT_CLOSE Then
            GUIDelete($hWndReportWindow)
            Exit
        EndIf
    WEnd
    Opt('GUIOnEventMode', $nOld) ; restore event mode
EndFunc

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