title: How make a click in button with windows AutomationElement
body: <p>Following this article 
  <a href="http://www.codeproject.com/Articles/141842/Automate-your-UI-using-Microsoft-Automation-Framew" rel="nofollow noreferrer">http://www.codeproject.com/Articles/141842/Automate-your-UI-using-Microsoft-Automation-Framew</a></p>
  
  <p>I'm trying to open an application and press a button. This is all that I want.</p>
  
  <pre><code>public RecordProgram()
      {
          ProcessStartInfo psi = new ProcessStartInfo(@"C:\MouseController.exe", @"C:\test1.mcd");
          psi.UseShellExecute = false;
          _calculatorProcess = Process.Start(psi);
  
          int ct = 0;
          do
          {
              _calculatorAutomationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "MouseController (1,0x)"));
              ++ct;
              Thread.Sleep(100);
          } 
          while (_calculatorAutomationElement == null &amp;&amp; ct &lt; 50);
  
          if (_calculatorAutomationElement == null)
          {
              throw new InvalidOperationException("Calculator must be running");
          }
  
          _resultTextBoxAutomationElement = _calculatorAutomationElement.FindFirst(TreeScope.Element, new PropertyCondition(AutomationElement.AutomationIdProperty, "920388"));
  
          if (_resultTextBoxAutomationElement == null)
          {
              throw new InvalidOperationException("Could not find result box");
          }
  
          GetInvokePattern(GetFunctionButton(Functions.Clear)).Invoke();
      }
  </code></pre>
  
  <p>The prograns run and open the executable with my file load But _resultTextBoxAutomationElement returns null value.</p>
  
  <pre><code>_resultTextBoxAutomationElement = _calculatorAutomationElement.FindFirst(TreeScope.Element, new PropertyCondition(AutomationElement.AutomationIdProperty, "920388"));
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/yGC1Y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yGC1Y.jpg" alt="enter image description here"></a></p>