# Function Reference

# _DebugSetup

Setup up a debug session using a specific reporting type

#include <Debug.au3>
_DebugSetup ( [$sTitle = Default [, $bBugReportInfos = False [, $vReportType = 1 [, $vLogFile = "" [, $bTimeStamp = False]]]]] )

## Parameters

$sTitle | [optional] Title to be displayed on the report window. Default value is "AutoIt Debug Report".
$bBugReportInfos | [optional] Display BugReport infos. Default value is False.
$vReportType | [optional] $DEBUG_REPORT_GUI (1) - Report Log Window (Default). $DEBUG_REPORT_CONSOLE (2) - ConsoleWrite. $DEBUG_REPORT_MSGBOX (3) - MsgBox. $DEBUG_REPORT_FILE (4) - FileWrite into $vLogFile defines the filename. $DEBUG_REPORT_NOTEPAD (5) - Report Notepad Window (see remark for Windows 11). $DEBUG_REPORT_GUITIMEOUT (6) - Report Log Window with timeout. $DEBUG_REPORT_GUIFILE (6) - Report Log Window and FileWrite. string - name of specific report function to be used.
$vLogFile | [optional] Name of the file if $vReportType = $DEBUG_REPORT_FILE or $DEBUG_REPORT_GUIFILE Timeout in sec, if $vReportType = 6$DEBUG_REPORT_GUITIMEOUT (Default = 10)
$bTimeStamp | [optional] True if every message must be prefixed with a timeStamp "YYYY/MM/DD HH:MM:SS"

## Return Value

Success: | the report type.
Failure: | sets the @error flag to non-zero.
@error: | 1 - if already called 2 - invalid report type 3 - invalid CallBack function

## Remarks

If a specific reporting function is registered then on AutoIt exit it is called without parameters.
You can only start one debug session at a time in the running script.
You can debug several concurrent scripts using the same debugging session, just use the same $sTitle when calling _DebugSetup(). All _DebugOut() will go to the same debugging session.
Commenting out the _DebugSetup() call will effectively disable all the calls to _Debug...(), but you may want to remove the calls to all _Debug...() functions before making a release version of your script.
If the $DEBUG_REPORT_GUI type is used then the script will end only when closing the report window.
If the $DEBUG_REPORT_NOTEPAD type is used the Notepad window cannot be closed when running under Windows 11 without asking to register it.
So the content of the window is put in the Clipboard and a MsgBox will display it before the closing of the script.
If the script is run in Admin mode the old Notepad will be used as for Windows 10 (see example 2).

## Related

_DebugOut, _DebugReport, _DebugReportEx, _DebugReportVar

## Example

### Example 1

    #cs ----------------------------------------------------------------------------

        AutoIt Version: 3.2.8.1
        Author:         David Nuttall

        Script Function:
        Base script to show functionality of Debug functions.

    #ce ----------------------------------------------------------------------------

    #include <Debug.au3>

    _DebugSetup("Check Excel", True) ; start displaying debug environment
    For $i = 1 To 4
        WinActivate("Microsoft Excel")
        ; interact with Excel
        Send("{Down}")
        _DebugOut("Moved Mouse Down") ; forces debug notepad window to take control
    Next

### Sample 2 script using Report Notepad Window (5)

    ; will allow to run with old Notepad behaviour in Window 11
    #RequireAdmin

    #include <Debug.au3>

    _DebugSetup("Check Excel", True, $DEBUG_REPORT_NOTEPAD) ; Report Notepad Window
    For $i = 1 To 4
        WinActivate("Microsoft Excel")
        ; interact with Excel
        Send("{Down}")
        _DebugOut("Moved Mouse Down") ; forces debug notepad window to take control
    Next

### Sample 3 script using Report Window and Log File ($DEBUG_REPORT_GUIFILE)

    #include <Debug.au3>

    Local $sLogFile = @TempDir & "\DebugLog.txt"
    FileDelete($sLogFile)

    _DebugSetup("Check Excel", True, $DEBUG_REPORT_GUIFILE, $sLogFile) ; Report Window and Log file
    For $i = 1 To 4
        WinActivate("Microsoft Excel")
        ; interact with Excel
        Send("{Down}")
        _DebugOut("Moved Mouse Down") ; forces debug notepad window to take control
    Next

    Run("Notepad.exe " & $sLogFile)