title: C# How to get tabs from chrome in multiple windows?
body: <p>So I have <a href="https://stackoverflow.com/questions/40070703/how-to-get-a-list-of-open-tabs-from-chrome-c-sharp">code</a> that extracts all the tabs from a window of chrome.</p>
  
  <p>However if I there are multiple windows open, only the most recent one is recognised. </p>
  
  <p>Is it possible to extract the tabs from multiple windows instead of only the most recent one?</p>
  
  <p>EDIT:
  The code that I use and needs fixing:</p>
  
  <pre><code>public List&lt;string&gt; ChromeTabs()
      {
          List&lt;string&gt; ret = new List&lt;string&gt;();
  
          Process[] procsChrome = Process.GetProcessesByName("chrome");
  
          if (procsChrome.Length &lt;= 0)
          {
              Console.WriteLine("Chrome is not running");
          }
          else
          {
              foreach (Process proc in procsChrome)
              {
                  // the chrome process must have a window 
  
                  if (proc.MainWindowHandle == IntPtr.Zero)
                  {
                      continue;
                  }
  
                  // to find the tabs we first need to locate something reliable - the 'New Tab' button 
                  AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
                  Condition condNewTab = new PropertyCondition(AutomationElement.NameProperty, "New Tab");
                  AutomationElement elmNewTab = root.FindFirst(TreeScope.Descendants, condNewTab);
  
                  // get the tabstrip by getting the parent of the 'new tab' button 
                  TreeWalker treewalker = TreeWalker.ControlViewWalker;
                  AutomationElement elmTabStrip = treewalker.GetParent(elmNewTab); // &lt;- Error on this line
  
                  // loop through all the tabs and get the names which is the page title 
                  Condition condTabItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem);
                  foreach (AutomationElement tabitem in elmTabStrip.FindAll(TreeScope.Children, condTabItem))
                  {
                      ret.Add(tabitem.Current.Name);
                      //Console.WriteLine(tabitem.Current.Name);
                  }
                  continue;
              }
          }
          return ret;
      }`
  </code></pre>