title: Check if a web is open in Chrome (C#)
body: <p>I am programming a .NET Framework application that open a website in Chrome and change it to full screen.
  The problem I am facing is to determine if the web is already open (I don't want to open multiple pages unnecessary), In that case the program should just switch the current active window to the correct tab and switch to full screen.</p>
  
  <p>The problem is only the active tab is visible to the C# program at a time, so the program needs to check each tab manually (by switching the active tab and check is title).
  I don't care if the screen is flickering throw all the tabs.</p>
  
  <p>I found this solution online:</p>
  
  <pre><code>        private void GetCaptionOfActiveWindow()
      {
          Process[] procs = Process.GetProcessesByName("Chrome");
  
          // to find the tabs we first need to locate something reliable - the 'New Tab' button 
          if (procs.Length == 0)
          {
              //some code to open chrome with the correct web site and change to full screen
              return;
          }
  
          IntPtr hWnd = IntPtr.Zero;
          int id = 0;
          int numTabs = procs.Length;
  
          foreach (Process p in procs)
          {
              if (p.MainWindowTitle.Length &gt; 0)
              {
                  hWnd = p.MainWindowHandle;
                  id = p.Id;
                  break;
              }
          }
  
          SetForegroundWindow(hWnd);
          SendKeys.SendWait("^1"); // change focus to first tab
          Thread.Sleep(100);
  
          int next = 1;
          string title;
  
          while (next &lt;= numTabs)
          {
              try
              {
                  title = Process.GetProcessById(id).MainWindowTitle.Replace(" - Google Chrome", "");
                  //richTextBox1.Text += title + "\n";
                  if (title.ToLower().Contains("some web site name"))
                  {
                      // some code to change the current active tab and change to full screen.
                      return;
                  }
                  next++;
                  SendKeys.SendWait("^{TAB}"); // change focus to next tab
                  Thread.Sleep(100);
              }
              catch (Exception ex)
              {
                  // Chrome internal process, doesn't have tab.
  
              }
          }
          //richTextBox1.Text += "web not exists\n";
          //some code to open new tab with the correct web site and change to full screen
      }
  </code></pre>
  
  <p>This solution works fine if all the Chrome tabs are open in the same window.
  My problem is to figure out what to do if the tabs are scatterd across multiple Chrome Windows.</p>