start at windows startup

This commit is contained in:
pypy
2020-03-21 18:00:47 +09:00
parent d1c84a8f25
commit 81694ec60a
3 changed files with 33 additions and 3 deletions

22
VRCX.cs
View File

@@ -134,5 +134,27 @@ namespace VRCX
{
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
{
}
}
}
}

View File

@@ -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;

View File

@@ -771,7 +771,7 @@
<el-switch v-model="discordActive"></el-switch>
</div>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">Instance Details</span>
<span style="display:inline-block;min-width:150px">Instance details</span>
<el-switch v-model="discordInstance"></el-switch>
</div>
</div>
@@ -794,11 +794,15 @@
<div style="margin-top:30px">
<span style="font-weight:bold">Window</span>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">Start as Minimized State</span>
<span style="display:inline-block;min-width:150px">Start at Windows startup</span>
<el-switch v-model="isStartAtWindowsStartup"></el-switch>
</div>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">Start as minimized state</span>
<el-switch v-model="isStartAsMinimizedState"></el-switch>
</div>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">Close to Tray</span>
<span style="display:inline-block;min-width:150px">Close to tray</span>
<el-switch v-model="isCloseToTray"></el-switch>
</div>
</div>