Skip to content

Disable UseShellExecute and bring the window to the front in case Ctrl + Click is used #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions BrowserSelect/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public partial class Form1 : Form
public Form1()
{
InitializeComponent();
MaximizeBox = false;
}

public void updateBrowsers()
Expand Down Expand Up @@ -253,7 +254,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();
}
Expand Down Expand Up @@ -284,7 +290,15 @@ private void center_me()
var top = wa.Height / 2 + wa.Top - Height / 2;

this.Location = new Point(left, top);
this.Activate();


// Borrowed from https://stackoverflow.com/a/5853542
// Get the window to the front
this.TopMost = true;
this.TopMost = false;

// "Steal" the focus
this.Activate();
}

private void btn_help_Click(object sender, EventArgs e)
Expand Down