Jump to content

How to stop script when using debug windows


Recommended Posts

  • Moderators

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 2 years later...
  • 3 months later...

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