/// <summary> /// Removes event handler for the specified window and element /// </summary> /// <param name="hWnd">window handle</param> /// <param name="autoEvent">the event to remove</param> /// <param name="element">the automation element</param> static public void RemoveAutomationEventHandler(IntPtr hWnd, AutomationEvent autoEvent, AutomationElement element) { Log.Debug("hWnd=" + hWnd); if (hWnd != IntPtr.Zero) { lock (WindowTable) { var windowElement = (WindowElement)WindowTable[hWnd]; if (windowElement != null) { var item = new RemoveEventHandlerItem { AutoEvent = autoEvent, AutoElement = element, WinElement = windowElement }; RemoveAutomationEvent(item); //windowElement.RemoveAutomationEventHandler(element, autoEvent); } } } }
/// <summary> /// Enqueues a request for the item for asynchronous handling /// </summary> /// <param name="item">item to add</param> private static void RemoveAutomationEvent(RemoveEventHandlerItem item) { _instance._queue.Enqueue(item); }