VAN0 Posted September 17, 2022 Posted September 17, 2022 Is there a way setup a system event listener, so it would execute a function when specific event id triggered? Currently I'm using task scheduler, where I created a new task that executes autoit script when triggered event id: It works, but I was hoping I could do this directly in the script instead. Any tips? Thank you.
KaFu Posted September 22, 2022 Posted September 22, 2022 (edited) Maybe create a looping eventlog listener? expandcollapse popup#include <EventLog.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> GUICreate("EventLog", 600, 300) Global $g_idMemo = GUICtrlCreateEdit("See console output", 2, 2, 596, 294, 0) GUICtrlSetFont($g_idMemo, 9, $FW_NORMAL, $GUI_FONTNORMAL, "Courier New") GUISetState(@SW_SHOW) ; Read most current event record $hEventLog = _EventLog__Open("", "Application") Do $aEvent = _EventLog__Read($hEventLog, True, False) ; read last event ; $hEventLog = _EventLog__Open("", "System") ; $aEvent = _EventLog__Read($hEventLog) ; $aEvent = _EventLog__Read($hEventLog, True, False) MemoWrite("Result ............: " & $aEvent[0]) MemoWrite("Record number .....: " & $aEvent[1]) MemoWrite("Submitted .........: " & $aEvent[2] & " " & $aEvent[3]) MemoWrite("Generated .........: " & $aEvent[4] & " " & $aEvent[5]) MemoWrite("Event ID ..........: " & $aEvent[6]) MemoWrite("Type ..............: " & $aEvent[8]) MemoWrite("Category ..........: " & $aEvent[9]) MemoWrite("Source ............: " & $aEvent[10]) MemoWrite("Computer ..........: " & $aEvent[11]) MemoWrite("Username ..........: " & $aEvent[12]) MemoWrite("Description .......: " & $aEvent[13]) MemoWrite("=====================================") Until GUIGetMsg() = $GUI_EVENT_CLOSE _EventLog__Close($hEventLog) ; Write a line to the memo control Func MemoWrite($sMessage) ConsoleWrite(TimerInit() & @TAB & $sMessage & @CRLF) ; GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Edited September 22, 2022 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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