title: How to Capture the Click event Using UI Automation in Outlook?
body: <p>I want to capture  button event of outlook using UI Automation. Right now i am able to get 'Property Change Event' like whenever iam minimizing or maximizing the WINWORD window the the event is raised instead of that i want to get the event on Send button click.    </p>
  
  <pre><code>private void SendButtonInvoke()
      {
  
          Process[] processes = Process.GetProcessesByName("WinWord");
          foreach (var item in processes)
          {
              aeOutLook = AutomationElement.FromHandle(item.MainWindowHandle);
          }
  
          AutomationElement buttonAddInstance =  aeOutLook.FindFirst(TreeScope.Descendants,
                 new PropertyCondition(AutomationElement.NameProperty, "Create a new message"));
  
          if (buttonAddInstance == null)
          {
              MessageBox.Show("Add button instance not found");
          }
          else
          {
              AutomationPropertyChangedEventHandler ButtonEvent =
                      new AutomationPropertyChangedEventHandler(OnStartInvoke);
  
              Automation.AddAutomationPropertyChangedEventHandler(buttonAddInstance, TreeScope.Element,
                  ButtonEvent, AutomationElement.NameProperty);   
          }
   } 
      private void OnStartInvoke(object src, AutomationEventArgs e)
      {
          //logic
          AutomationElement ar2 = src as AutomationElement;
          MessageBox.Show("Invoked Sucessfully");
      }
  </code></pre>