Jump to content

Recommended Posts

Posted

Definately working, x86 and x64.

I modified your script slightly:

    Removed the Example function.
    Saved the Script as DebugCapture.au3
    (Your script is now used as a UDF)

Then I slighty modified Autoitter's DebugViewer script:

;===================================================================================================
;
; Script Name     : DebugViewer
;
; Script Function : Example using the DebugCapture UDF
;
; Link : https://www.autoitscript.com/forum/topic/82889-capture-debug-information-udf/
;
; AutoIt Version  : 3.2.12.1
; Script version  : 1.0
; Date            : 19-10-2008
; Author          : Steven Scholte (a.k.a. autoitter)
;
;===================================================================================================

AutoItSetOption("MustDeclareVars", 1)
AutoItSetOption("TrayAutoPause",   0)

#include "DebugCapture.au3"
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include "GuiListView.au3"

Global $MainForm = GUICreate("Debug Viewer", 600, 300, -1, -1)
Global $ListViewDebug = GUICtrlCreateListView("Time|PID|Debug Output", 16, 17, 571, 212)
GUICtrlSendMsg($ListViewDebug, 0x101E, 0, 60)
GUICtrlSendMsg($ListViewDebug, 0x101E, 1, 50)
GUICtrlSendMsg($ListViewDebug, 0x101E, 2, 440)
Global $ButtonStart = GUICtrlCreateButton("Start", 417, 250, 75, 30, 0)
Global $ButtonStop = GUICtrlCreateButton("Stop", 505, 250, 75, 30, 0)
GUICtrlSetState($ButtonStop, $GUI_DISABLE)
GUISetState(@SW_SHOW)

; Global variables
Global $bCapturing = False
Global $iIndex
Global $iPid
Global $strData

; Main loop
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            If $bCapturing Then StopDebugCapture()
            Exit
        Case $ButtonStart
            StartCapture()
        Case $ButtonStop
            StopCapture()
    EndSwitch
    If $bCapturing Then
        $strData = GetDebugOutput()
        If (Not @error) And ($strData <> "") Then
            $iPid = @extended
            $iIndex = _GUICtrlListView_AddItem($ListViewDebug, @HOUR & ":" & @MIN & ":" & @SEC) ; Add time
            _GUICtrlListView_AddSubItem($ListViewDebug, $iIndex, $iPid, 1)                      ; Add PID
            _GUICtrlListView_AddSubItem($ListViewDebug, $iIndex, StringStripWS($strData, 2), 2) ; Add debug information (remove trailing CR/LF)
            _GUICtrlListView_EnsureVisible($ListViewDebug, $iIndex)                             ; Scroll into view
        EndIf
    EndIf
    Sleep(10)                                               ; Helps to keep CPU load low
WEnd

Func StartCapture()
    If Not $bCapturing Then
        StartDebugCapture()
        Switch @error
            Case 0
                $bCapturing = True
                GUICtrlSetState($ButtonStart, $GUI_DISABLE)
                GUICtrlSetState($ButtonStop,  $GUI_ENABLE)
            Case 1
                MsgBox(16, @ScriptName, "Error loading DebugCapture.dll", 0, $MainForm)
            Case 2
                MsgBox(16, @ScriptName, "Initialization failed.", 0, $MainForm)
            Case 3
                MsgBox(64, @ScriptName, "Another debugger is already active.", 0, $MainForm)
        EndSwitch
    EndIf
EndFunc

Func StopCapture()
    If $bCapturing Then
        StopDebugCapture()
        $bCapturing = False
        GUICtrlSetState($ButtonStart, $GUI_ENABLE)
        GUICtrlSetState($ButtonStop,  $GUI_DISABLE)
    EndIf
EndFunc

Give it a try Nine, may help.

Posted (edited)
3 hours ago, Nine said:

Enjoy.

Will do!

 

Earlier, I didn't get the chance to test your script any further.

Your code works with filters, that's all I need.

 

Many thanks for your efforts Nine 🏆

Edited by TwoCanoe
mmm.. spelling!

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