TwoCanoe Posted February 14 Author Posted February 14 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: expandcollapse popup;=================================================================================================== ; ; 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. argumentum 1
Nine Posted February 14 Posted February 14 2 hours ago, TwoCanoe said: I modified your script slightly No problem. It was fun to make it work. Enjoy. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
TwoCanoe Posted February 15 Author Posted February 15 (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 February 15 by TwoCanoe mmm.. spelling!
TwoCanoe Posted June 30 Author Posted June 30 Update! While the debug capture script definitely works, it causes problems with any other running software that use windows debug messages. Took a while to notice this problem. Here’s my example: I was running PowerDVD, just listening to a DVD box set while I was testing my debug capture script. I noticed that PowerDVD would hang/crash if the script was running. It was not obvious to begin with, PowerDVD can throw a tantrum if DVD needs a clean, so I didn’t see the connection to my script up straight away. PowerDVD uses debug messages under normal operation and the script was interfering. Also affects VLC player, any (all?) Stardock software, and I assume a lot more software packages that make use of windows debug messages. I have (re-)tested using the DebugCapture.dll: https://www.autoitscript.com/forum/topic/82889-capture-debug-information-udf/ and Argumentum’s solution in this thread. Both result in the same lockup/crash problem. For what I am trying to achieve I need the script to be constantly running. If the script causes problems with software then using debug scripts are obviously not the solution, for me anyway. As said, the DebugCapture.dll and Argumentum’s script works perfectly well on their own. Hopefully this post will save others some problems trying something similar to what I was hoping to do. Sysinternals Debugview and DebugView++ do not cause software to hang or crash. So it is possible. Both can be run using the command line. Originally, I tried Stdout scripts on both but was sketchy, though that was probably my scripting! I might have another look into this, or… I may have another cunning plan/solution. I can capture the USB data of my keyboard using Wireshark & USBPcap. If I can monitor the USB data somehow, then maybe I can find a good alternative to using windows debug messages.
TwoCanoe Posted June 30 Author Posted June 30 I tried again using a Stdout script along with the small command line version of DebugView++. Ran my test script while VLC Player was running, no problems/hangs/crashes encountered. Ran my test script while PowerDVD was running and again no problems encountered. Here is my test script: #include <AutoItConstants.au3> HotKeySet("{Esc}", "Terminate") Local $CMD = 'DebugViewConsole-small.exe -a -c -f -i "deviceModeChangedCallbackEvent:" -i "json_event[{"isEnabled":true}]" -i "json_event[{"isEnabled":false}]"' Local $PID = Run('"' & @ComSpec & '" /k ' & $CMD, "", @SW_HIDE, $STDOUT_CHILD); Local $strData Local $strEvent = 'deviceModeChangedCallbackEvent:' ; Windows debug message/event to wait for. Local $strKeyDn = 'json_event[{"isEnabled":true}]' ; 'Fn' key down on Razer keyboard. Local $strKeyUp = 'json_event[{"isEnabled":false}]' ; 'Fn' key up on Razer keyboard. While ProcessExists($PID) $strData = StdoutRead($PID) If StringInStr($strData, $strEvent) Then If StringInStr($strData, $strKeyDn) Then MsgBox(0, "Event", "Fn key down") If StringInStr($strData, $strKeyUp) Then MsgBox(0, "Event", "Fn key up") EndIf sleep(10) WEnd Func Terminate() Run('"' & @ComSpec & '" /k ' & 'DebugViewConsole-small -x', "", @SW_HIDE) ; Kill all DebugView++ instances. Exit EndFunc As far as I can tell, after a couple of hours testing, everything is works without any problems. It is a pity that I had to use a third-party app though. Oh well.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now