; #Region Options AutoItSetOption("MustDeclareVars", 1) ; ; Set desired Option values ;Default value is listed first Opt("CaretCoordMode", 0) ;1=absolute, 0=relative, 2=client Opt("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand Opt("ExpandVarStrings", 0) ;0=don't expand, 1=do expand Opt("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell Opt("GUIDataSeparatorChar", "|") ;"|" is the default Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled Opt("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing Opt("GUIEventOptions", 0) ;0=default, 1=just notification, 2=GuiCtrlRead tab index Opt("MouseClickDelay", 20) ;10 milliseconds Opt("MouseClickDownDelay", 20) ;10 milliseconds Opt("MouseClickDragDelay", 250) ;250 milliseconds Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declare Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't Opt("SendKeyDelay", 250) ;10 milliseconds Opt("SendKeyDownDelay", 20) ;10 milliseconds Opt("TCPTimeout", 100) ;100 milliseconds Opt("TrayAutoPause", 1) ;0=no pause, 1=Pause Opt("TrayIconDebug", 1) ;0=no info, 1=debug line info Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon Opt("TrayMenuMode", 0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode", 0) ;0=disable, 1=enable Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect Opt("WinSearchChildren", 1) ;0=no, 1=search children also Opt("WinTextMatchMode", 1) ;1=complete, 2=quick Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Opt("WinWaitDelay", 750) ;250 milliseconds #EndRegion Options #include #include #include #include #include #include #include #include #include #include Global $nMsg ;#include Global $hMainGUI = GUICreate("EventLog", 615, 545, 393, 218, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME)) Global $bApplication = GUICtrlCreateButton("Application", 16, 8, 75, 25) GUICtrlSetBkColor(-1, 0xFFFF00) Global $bSecurity = GUICtrlCreateButton("Security", 168, 8, 75, 25) GUICtrlSetBkColor(-1, 0x00FFFF) Global $bSetup = GUICtrlCreateButton("Setup", 352, 8, 75, 25) GUICtrlSetBkColor(-1, 0xFF00FF) Global $bSystem = GUICtrlCreateButton("System", 512, 8, 75, 25) GUICtrlSetBkColor(-1, 0xFF0000) ;Global $g_idMemo = GUICtrlCreateEdit("", 8, 40, 593, 497, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) Global $g_idMemo = _GUICtrlRichEdit_Create($hMainGUI, "", 8, 40, 593, 497, $ES_AUTOHSCROLL+$ES_AUTOVSCROLL+$WS_HSCROLL+$WS_VSCROLL+$ES_LEFT+$ES_MULTILINE+$ES_READONLY) GUICtrlSetFont($g_idMemo, 8, 400, 0, "Courier New") GUICtrlSetResizing($g_idMemo, $GUI_DOCKAUTO) GUISetState(@SW_SHOW) ; ; Note, need to change to RichEdit control... Edit the EventLogNotifyForm ;Global $g_idMemo = _GUICtrlRichEdit_Create($hMainGUI, "", 8, 40, 593, 497, $ES_AUTOHSCROLL+$ES_AUTOVSCROLL+$WS_HSCROLL+$WS_VSCROLL+$ES_LEFT+$ES_MULTILINE+$ES_READONLY) _GUICtrlRichEdit_SetFont($g_idMemo, 8, "Courier New"); Global $aData[4] = [3, 1, 2, 3] Global $MaxEvent = 4; Global $cApplication = 0, $cSecurity = 1, $cSetup = 2, $cSystem = 3 Global $cStr[$MaxEvent], $iCount[$MaxEvent], $iColor[$MaxEvent] Global $iMsg, $i; Main() Func Main() Local $hEvent, $Id ; Set up event $cStr[$cApplication] = "Application" $cStr[$cSecurity ] = "Security" $cStr[$cSetup ] = "Setup" $cStr[$cSystem ] = "System" $iColor[$cApplication] = $CLR_YELLOW; $iColor[$cSecurity ] = $CLR_AQUA; $iColor[$cSetup ] = $CLR_FUCHSIA; $iColor[$cSystem ] = $CLR_RED; for $i = 0 to ($MaxEvent-1) $hEvent = _EventLog__Open("", $cStr[$i]) $iCount[$i] = _EventLog__Count($hEvent); _EventLog__Close($hEvent) Next ; Loop until the user exits. Do $iMsg = GUIGetMsg() $Id = -1 ;ConsoleWrite('>GUIGetMgs = ' & $iMsg & @CRLF) Switch $iMsg Case $bApplication $Id = $cApplication Case $bSecurity $Id = $cSecurity Case $bSetup $Id = $cSetup Case $bSystem $Id = $cSystem Case $GUI_EVENT_CLOSE ;sgBox($MB_SYSTEMMODAL, "GUI Event", "You selected the Close button. Exiting...") ExitLoop Case $GUI_EVENT_NONE for $i = 0 to ($MaxEvent-1) PostEvent ($i); Next EndSwitch if ($Id >= 0) Then ConsoleWrite('Button ' & $cStr[$Id] & ' was pressed' & @CRLF) $hEvent = _EventLog__Open("", $cStr[$Id]) _EventLog__Report($hEvent, 4, 0, 22, $cStr[$Id], "AutoIt3 generated event", $aData) MsgBox($MB_SYSTEMMODAL, "GUI Event", "You created an " & $cStr[$Id] & " Application Event") _EventLog__Close($hEvent) EndIf ;Sleep(500); Until $iMsg = $GUI_EVENT_CLOSE GUIDelete($g_idMemo) EndFunc ;==>Example ; Write a line to the memo control Func MemoWrite($sMessage, ByRef $Idx) ;GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) _GUICtrlRichEdit_SetCharBkColor($g_idMemo, $iColor[$Idx]); _GUICtrlRichEdit_AppendText($g_idMemo, $sMessage & @CRLF) EndFunc ;==>MemoWr Func PostEvent(ByRef $Idx) Local $hEvent Local $aEvent $hEvent = _EventLog__Open("", $cStr[$Idx]) Local $iNewCount = _EventLog__Count($hEvent); While ($iNewCount > $iCount[$Idx]) $aEvent = _EventLog__Read($hEvent, True, False) ; read last event ConsoleWrite("Src:" & $aEvent[10] & " Idx:" & $Idx & " Count:" & $iCount[$Idx] & " New:" & $iNewCount & " Color:" & $iColor[$Idx] & @CRLF) ;if ($cStr[$Idx] = $aEvent[10]) Then MemoWrite("Result ............: " & $aEvent[0], $Idx) MemoWrite("Record number .....: " & $aEvent[1], $Idx) MemoWrite("Submitted .........: " & $aEvent[2] & " " & $aEvent[3], $Idx) MemoWrite("Generated .........: " & $aEvent[4] & " " & $aEvent[5], $Idx) MemoWrite("Event ID ..........: " & $aEvent[6], $Idx) MemoWrite("Event Type ........: " & $aEvent[7], $Idx) MemoWrite("Type ..............: " & $aEvent[8], $Idx) MemoWrite("Category ..........: " & $aEvent[9], $Idx) MemoWrite("Source ............: " & $aEvent[10], $Idx) MemoWrite("Computer ..........: " & $aEvent[11], $Idx) MemoWrite("Username ..........: " & $aEvent[12], $Idx) MemoWrite("Description .......: " & $aEvent[13], $Idx) ;MemoWrite("Data Array ........: " & $aEvent[14], $Idx) MemoWrite("", $Idx) ;EndIf $iCount[$Idx] = $iCount[$Idx] + 1; WEnd _EventLog__Close($hEvent) EndFunc