Jump to content
Sign in to follow this  
Patchworks

How to stop script when using debug windows

Recommended Posts

Patchworks

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

Share this post


Link to post
Share on other sites
Melba23

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
ferrix

For what it's worth, the WinClose approach did not work for me.  I had better luck with:

GUIDelete( WinGetHandle( $sTitle) )

Where sTitle is defined as in the Melba23 post.

Edited by ferrix

Share this post


Link to post
Share on other sites
therealhanuta

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

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  

×