// Runs on our Automation thread (via SyncContext passed into the constructor) // CONSIDER: Performance impact of logging (including GetClassName) here void OnWinEventReceived(object winEventArgsObj) { var winEventArgs = (WinEventArgs)winEventArgsObj; #if DEBUG Logger.WinEvents.Verbose($"{winEventArgs.EventType} - Window {winEventArgs.WindowHandle:X} ({Win32Helper.GetClassName(winEventArgs.WindowHandle)} - Object/Child {winEventArgs.ObjectId} / {winEventArgs.ChildId} - Thread {winEventArgs.EventThreadId} at {winEventArgs.EventTimeMs}"); #endif WinEventReceived?.Invoke(this, winEventArgs); }
// Runs on our Automation thread (via SyncContext passed into the constructor) // CONSIDER: Performance impact of logging (including GetClassName) here void OnWinEventReceived(object winEventArgsObj) { var winEventArgs = (WinEventArgs)winEventArgsObj; #if DEBUG if (winEventArgs.ObjectId != WinEventObjectId.OBJID_CURSOR) { //Logger.WinEvents.Verbose(string.Format("{winEventArgs.EventType} - Window {winEventArgs.WindowHandle:X} ({Win32Helper.GetClassName(winEventArgs.WindowHandle)} - Object/Child {winEventArgs.ObjectId} / {winEventArgs.ChildId} - Thread {winEventArgs.EventThreadId} at {winEventArgs.EventTimeMs}"); Logger.WinEvents.Verbose(string.Format("{0} - Window {1:X} ({2} - Object/Child {3} / {4} - Thread {5} at {6}", winEventArgs.EventType, winEventArgs.WindowHandle, Win32Helper.GetClassName(winEventArgs.WindowHandle), winEventArgs.ObjectId, winEventArgs.ChildId, winEventArgs.EventThreadId, winEventArgs.EventTimeMs)); } #endif WinEventReceived.Invoke(this, winEventArgs); }
// Runs on our Automation thread (via SyncContext passed into the constructor) // CONSIDER: Performance impact of logging (including GetClassName) here void OnWinEventReceived(object winEventArgsObj) { var winEventArgs = (WinEventArgs)winEventArgsObj; if (winEventArgs.ObjectId == WinEventObjectId.OBJID_CURSOR) { return; } #if DEBUG Logger.WinEvents.Verbose($"{winEventArgs.EventType} - Window {winEventArgs.WindowHandle:X} {(winEventArgs.WindowHandle != IntPtr.Zero ? Win32Helper.GetClassName(winEventArgs.WindowHandle) : "")} - Object/Child {winEventArgs.ObjectId} / {winEventArgs.ChildId} - Thread {winEventArgs.EventThreadId} at {winEventArgs.EventTimeMs}"); #endif WinEventReceived?.Invoke(this, winEventArgs); }