From 81694ec60a69b338fd92bca6a60c5860e7d2408d Mon Sep 17 00:00:00 2001 From: pypy Date: Sat, 21 Mar 2020 18:00:47 +0900 Subject: [PATCH] start at windows startup --- VRCX.cs | 22 ++++++++++++++++++++++ html/app.js | 4 ++++ html/index.html | 10 +++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/VRCX.cs b/VRCX.cs index 1f446cc57..acc91b194 100644 --- a/VRCX.cs +++ b/VRCX.cs @@ -134,5 +134,27 @@ public float CpuUsage() { return CpuMonitor.CpuUsage; } + + public void SetStartup(bool enabled) + { + try + { + using (var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) + { + if (enabled) + { + var path = Application.ExecutablePath; + key.SetValue("VRCX", $"\"{path}\" --startup"); + } + else + { + key.DeleteValue("VRCX", false); + } + } + } + catch + { + } + } } } \ No newline at end of file diff --git a/html/app.js b/html/app.js index 96b8a7705..6cc87b0fd 100644 --- a/html/app.js +++ b/html/app.js @@ -5304,12 +5304,16 @@ CefSharp.BindObjectAsync( VRCXStorage.SetBool('isDarkMode', this.isDarkMode); $appDarkStyle.disabled = this.isDarkMode === false; }; + $app.data.isStartAtWindowsStartup = VRCXStorage.GetBool('VRCX_StartAtWindowsStartup'); $app.data.isStartAsMinimizedState = VRCXStorage.GetBool('VRCX_StartAsMinimizedState'); $app.data.isCloseToTray = VRCXStorage.GetBool('VRCX_CloseToTray'); var saveVRCXWindowOption = function () { + VRCXStorage.SetBool('VRCX_StartAtWindowsStartup', this.isStartAtWindowsStartup); VRCXStorage.SetBool('VRCX_StartAsMinimizedState', this.isStartAsMinimizedState); VRCXStorage.SetBool('VRCX_CloseToTray', this.isCloseToTray); + VRCX.SetStartup(this.isStartAtWindowsStartup); }; + $app.watch.isStartAtWindowsStartup = saveVRCXWindowOption; $app.watch.isStartAsMinimizedState = saveVRCXWindowOption; $app.watch.isCloseToTray = saveVRCXWindowOption; diff --git a/html/index.html b/html/index.html index e74c195a8..b8924d26e 100644 --- a/html/index.html +++ b/html/index.html @@ -771,7 +771,7 @@
- Instance Details + Instance details
@@ -794,11 +794,15 @@
Window
- Start as Minimized State + Start at Windows startup + +
+
+ Start as minimized state
- Close to Tray + Close to tray