Jump to content

_DebugOut - Close or Kill Report Log Window


Rugbee
 Share

Recommended Posts

Hey Folks,

I have an autoit script that runs (monitors) a local system for a specific process. When the process is detected it completes an action but does not close. The script runs all the time and works great.

To assist field techs with troubleshooting I wanted to use _DebugSetup() to open the Report Log Window and display _debugOut lines within my code to indicate what is going on with the script while it is running. I have created a taskmenuitem that can be checked off to initiate the Debug output. This also works great. I would like to be able to deselect the menu item and have the debug stop or at a minimum have the Report Log Window close. I know that it will stop debuging if I kill the script, but I wish for the script to remain running.

Here is an example of what I want to accomplish:

#include <constants.au3>
#include <debug.au3>
Opt("WinTitleMatchMode",2)
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode", 1)


TraySetClick(16)
$DebugMenuItem = TrayCreateItem("Debug")
TrayItemSetOnEvent(-1,"_CheckTrayItem")
TraySetState()


While 1
    _DebugOut("No Process detected... Looping")
    Sleep(5000)
    While ProcessExists("notepad.exe")
        _DebugOut("Process detected Perform action...")
        MsgBox(0,'','Perform Action')
        Sleep(2000)
    WEnd
WEnd

Func _CheckTrayItem()
    $Checkbox = TrayItemGetState($DebugMenuItem)
    IF $Checkbox = '65' Then
        _Debug()
    Else
        MsgBox(0,'','This is where I want to Kill the Debug')
    EndIf
EndFunc
Func _Debug()
    _DebugSetup("DEBUGLOG - " & @ScriptName)
    _DebugBugReportEnv()
    _DebugOut('User: ' & @UserName  & ' Computer: ' & @ComputerName & ' Date: ' & @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC)
    _DebugOut('******************SCRIPT START************************')
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...