From 1da0ad7f13d075b4aa7e106d07770528fe985d45 Mon Sep 17 00:00:00 2001 From: Jasper T <> Date: Fri, 9 Apr 2021 23:01:40 -0500 Subject: [PATCH 1/2] Disable UseShellExecute and bring the window to front from UWP apps --- BrowserSelect/Form1.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/BrowserSelect/Form1.cs b/BrowserSelect/Form1.cs index 420c3e4..4dfb605 100644 --- a/BrowserSelect/Form1.cs +++ b/BrowserSelect/Form1.cs @@ -253,7 +253,12 @@ public static void open_url(Browser b, bool incognito = false) } else { - Process.Start(b.exec, Program.Args2Str(args)); + ProcessStartInfo startInfo = new ProcessStartInfo(b.exec); + // Clicking MS Edge takes more than 4 seconds to load, even with an existing window + // Disabling UseShellExecute to create the process directly from the browser executable file + startInfo.UseShellExecute = false; + startInfo.Arguments = Program.Args2Str(args); + Process.Start(startInfo); } Application.Exit(); } @@ -285,6 +290,11 @@ private void center_me() this.Location = new Point(left, top); this.Activate(); + // Bring BrowserSelect up front if link is clicked inside UWP apps, notably Windows Terminal + this.WindowState = FormWindowState.Normal; + this.BringToFront(); + this.TopMost = true; + this.Focus(); } private void btn_help_Click(object sender, EventArgs e) From c31cdb125aef3c9b178895030cfa4f07e26860a2 Mon Sep 17 00:00:00 2001 From: Jasper T <> Date: Sat, 10 Apr 2021 00:25:37 -0500 Subject: [PATCH 2/2] Bring window to the front and steal focus in case user CTRL - Click to follow links --- BrowserSelect/Form1.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/BrowserSelect/Form1.cs b/BrowserSelect/Form1.cs index 4dfb605..e261412 100644 --- a/BrowserSelect/Form1.cs +++ b/BrowserSelect/Form1.cs @@ -19,6 +19,7 @@ public partial class Form1 : Form public Form1() { InitializeComponent(); + MaximizeBox = false; } public void updateBrowsers() @@ -289,12 +290,15 @@ private void center_me() var top = wa.Height / 2 + wa.Top - Height / 2; this.Location = new Point(left, top); - this.Activate(); - // Bring BrowserSelect up front if link is clicked inside UWP apps, notably Windows Terminal - this.WindowState = FormWindowState.Normal; - this.BringToFront(); + + + // Borrowed from https://stackoverflow.com/a/5853542 + // Get the window to the front this.TopMost = true; - this.Focus(); + this.TopMost = false; + + // "Steal" the focus + this.Activate(); } private void btn_help_Click(object sender, EventArgs e)