mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-10 20:45:38 +02:00
ctrl exit to test restart
This commit is contained in:
parent
665aed45f7
commit
2b0c470ce5
2 changed files with 11 additions and 5 deletions
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue