title: How to Set Focus Back To Calling Form After Starting A Process (Chrome)
body: <p>I open up a Chrome browser window from my program using Process.Start() but the new opened chrome browser tab(s) covers the screen. But I want my application to maintain its focus after creating these chrome browser tab(s).</p>
  <p>I will have one brower window open but several chrome tabs showing different URLs.</p>
  <p>Here is what I've tried which is similar to the answer at <a href="https://stackoverflow.com/questions/8881038/how-to-set-focus-back-to-form-after-opening-up-a-process-notepad">How to set focus back to form after opening up a process (Notepad)?</a>. But doesn't work for me.</p>
  <pre><code>[DllImport(&quot;user32.dll&quot;)]
  [return: MarshalAs(UnmanagedType.Bool)]
  static extern bool SetForegroundWindow(IntPtr hWnd)
  
  // this code will get called several times with a different URL in Arguments property
  
  Process p = new Process();
  p.StartInfo = new ProcessStartInfo(&quot;Chrome.exe&quot;);
  p.StartInfo.CreateNoWindow = true;
  
  p.StartInfo.Arguments = &quot;https:/google.com&quot;;
  p.Start();
  
  p.WaitForInputIdle();
  SetForegroundWindow(this.Handle);
  </code></pre>