Skip to content

Commit

Permalink
start at windows startup
Browse files Browse the repository at this point in the history
  • Loading branch information
pypy-vrc committed Mar 21, 2020
1 parent d1c84a8 commit 81694ec
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
22 changes: 22 additions & 0 deletions VRCX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
}
}
}
4 changes: 4 additions & 0 deletions html/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 7 additions & 3 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down

0 comments on commit 81694ec

Please sign in to comment.