title: Invoke method not working on a windows open dialog box
body: <p>I've trying to do some automation with Microsoft UI automation with C# and on the first step I tried to do some automation with notepad. What I've tried to achieve that to start notepad and open a txt file from a random place.</p>
  
  <p>What I've already achieved:</p>
  
  <ul>
  <li>Open notepad</li>
  <li>Invoke(expand) the filemenu and Invoke(click) on the "Open..." button.</li>
  <li>Write the path of the filename into the File name textbox of the popup Open dialog box (strangely I'm not able to Invoke a click action onto the address bar, but to handle that, that is going to be the next task).</li>
  </ul>
  
  <p>Program.cs</p>
  
  <pre><code>using System;
  using System.Linq;
  using System.Threading;
  using System.Diagnostics;
  using System.Windows.Forms;
  using System.Windows.Automation;
  using System.Runtime.InteropServices;
  
  
  namespace TestUIAutomation
  {
  
      class Program
      {
  
          [DllImport("user32.dll")]
          public static extern int SetForegroundWindow(IntPtr hWnd);
  static void Main(string[] args)
  {
      Process p = Process.Start(@"notepad.exe");
      SetForegroundWindow(p.MainWindowHandle);
  
      Thread.Sleep(1000);
  
      var baseSoftware = AutomationElement.RootElement.FindFirst(TreeScope.Children, new 
      PropertyCondition(AutomationElement.NameProperty, "Untitled - Notepad"));
  
      var fileButton = baseSoftware.FindFirst(TreeScope.Descendants, new 
      propertyCondition(AutomationElement.NameProperty, "File"));
  
      var fileButtonExpand = Utilitiy.ExCoPattern(fileButton);
  
      if (fileButtonExpand.Current.ExpandCollapseState != ExpandCollapseState.Expanded)
              {
                  fileButtonExpand.Expand();
              }
  
      var openButton = baseSoftware.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Open..."));
              Utilitiy.GetInvokePattern(openButton).Invoke();
  
      Thread.Sleep(1000);
  
      var addressBar = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "File name:"));
  
      SendKeys.SendWait(@"C:\Users\user1\Documents\Test.txt");
  
      var findOpenButton = new AndCondition(new PropertyCondition(AutomationElement.NameProperty, "Open"), new PropertyCondition(AutomationElement.AutomationIdProperty, "1"));
  
  
      var openButtonDialog = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, findOpenButton);
  
      Utilitiy.GetInvokePattern(openButtonDialog);
  }
  }
  }
  </code></pre>
  
  <p>Utility cs</p>
  
  <pre><code>using System;
  using System.Windows.Automation;
  
  namespace TestUIAutomation
  {
      class Utilitiy
      {
          public static void SetCombobValueByUIA(AutomationElement ctrl, string newValue)
          {
              ExpandCollapsePattern exPat = ctrl.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
  
              if (exPat == null)
              {
                  throw new ApplicationException("Bad Control type...");
              }
  
              exPat.Expand();
  
              AutomationElement itemToSelect = ctrl.FindFirst(TreeScope.Descendants, new
                                    PropertyCondition(AutomationElement.NameProperty, newValue));
  
              SelectionItemPattern sPat = itemToSelect.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
              sPat.Select();            
          }
          public static InvokePattern GetInvokePattern(AutomationElement element)
          {
              return element.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
          }
          public static TogglePattern CheckBoxPattern(AutomationElement element)
          {
              return element.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;
          }
          public static SelectionItemPattern RadioButtonPattern(AutomationElement element)
          {
              return element.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
          }
          public static ValuePattern TextValuePattern(AutomationElement element)
          {
              return element.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
          }
          public static ExpandCollapsePattern ExCoPattern(AutomationElement element)
          {
              return element.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
          }
      }
  }
  </code></pre>
  
  <p>The problem at the moment I won't receive any error message, so the program actually invoke the open button but in real life nothing happens.
  I can use sendkeys method enter input to open the file but if it's possible I like to invoke the open button.</p>