Exemple #1
0
        private void SelectionChanged(object sender, AutomationEventArgs e)
        {
            AutomationElement element = sender as AutomationElement;

            if (IsInvalidAutomationElement(element))
            {
                return;
            }

            Debug.WriteLine("Selection changed. Sender: " + element.Current.Name);
            ExplorerSelectionChanged?.Invoke(this, new IntPtr(lastTopLevelWindow.Current.NativeWindowHandle));
        }
 private void OnMessage(XDMessageEventArgs msg)
 {
     if (msg.DataGram.Channel == "SelectionOfExplorerWindowChanged")
     {
         if (int.TryParse(msg.DataGram.Message, out int hwndInteger))
         {
             IntPtr hwnd = new IntPtr(hwndInteger);
             ExplorerSelectionChanged?.Invoke(this, new ExplorerMonitorEventArgs(hwnd));
         }
     }
     else if (msg.DataGram.Channel == "ExplorerWindowGotFocus")
     {
         if (int.TryParse(msg.DataGram.Message, out int hwndInteger))
         {
             IntPtr hwnd = new IntPtr(hwndInteger);
             ExplorerWindowGotFocus?.Invoke(this, new ExplorerMonitorEventArgs(hwnd));
         }
     }
 }