diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs index 2741cd2..fd0b9ab 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs @@ -349,7 +349,7 @@ if not errorlevel 1 goto wait_to_finish"; if (relaunch_delay > 0) { - RestartHidden(relaunch_delay); + Restart(relaunch_delay); return; } @@ -428,11 +428,11 @@ if not errorlevel 1 goto wait_to_finish"; Log.Error("taskbar not ready, restart PersistentWindows"); } - RestartHidden(1); + Restart(1); return false; } - static void RestartHidden(int delay) + static public void Restart(int delay, bool hidden = true) { Process p = new Process(); string batFile = Path.Combine(AppdataFolder, $"pw_restart.bat"); @@ -441,8 +441,11 @@ if not errorlevel 1 goto wait_to_finish"; content += "\nstart \"\" /B \"" + Path.Combine(Application.StartupPath, Application.ProductName) + ".exe\" " + "-wait_taskbar " + Program.CmdArgs; File.WriteAllText(batFile, content); p.StartInfo.FileName = batFile; - p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - p.StartInfo.UseShellExecute = true; + if (hidden) + { + p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + p.StartInfo.UseShellExecute = true; + } p.Start(); Log.Error("program restarted"); diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs index 11b752e..8d8e45f 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/SystrayForm.cs @@ -445,6 +445,9 @@ namespace PersistentWindows.SystrayShell private void ExitToolStripMenuItemClickHandler(object sender, EventArgs e) { + bool ctrl_key_pressed = (User32.GetKeyState(0x11) & 0x8000) != 0; + if (ctrl_key_pressed) + Program.Restart(2, hidden:false); Exit(); }