diff --git a/Dotnet/AppApi/GameHandler.cs b/Dotnet/AppApi/GameHandler.cs index 75c72c3a..3544bed0 100644 --- a/Dotnet/AppApi/GameHandler.cs +++ b/Dotnet/AppApi/GameHandler.cs @@ -15,7 +15,7 @@ namespace VRCX CheckGameRunning(); } - + /// /// Checks if the VRChat game and SteamVR are currently running and updates the browser's JavaScript function $app.updateIsGameRunning with the results. /// @@ -40,7 +40,7 @@ namespace VRCX if (MainForm.Instance?.Browser != null && !MainForm.Instance.Browser.IsLoading && MainForm.Instance.Browser.CanExecuteJavascriptInMainFrame) MainForm.Instance.Browser.ExecuteScriptAsync("$app.updateIsGameRunning", isGameRunning, isSteamVRRunning, isHmdAfk); } - + /// /// Kills the VRChat process if it is currently running. /// @@ -54,6 +54,29 @@ namespace VRCX return processes.Length; } + /// + /// Kills the install.exe process after exiting game. + /// + /// Whether the process is killed (true or false). + public bool KillInstall() + { + bool isSuccess = false; + var processes = Process.GetProcessesByName("install"); + foreach (var p in processes) + { + // "E:\SteamLibrary\steamapps\common\VRChat\install.exe" + var match = Regex.Match(p.MainModule.FileName, "(.+?\\\\VRChat.*)(!?\\\\install.exe)"); + if (match.Success) + { + p.Kill(); + isSuccess = true; + break; + } + } + + return isSuccess; + } + /// /// Starts the VRChat game process with the specified command-line arguments. /// @@ -71,13 +94,13 @@ namespace VRCX var path = match.Groups[1].Value; // var _arguments = Uri.EscapeDataString(arguments); Process.Start(new ProcessStartInfo - { - WorkingDirectory = path, - FileName = $"{path}\\steam.exe", - UseShellExecute = false, - Arguments = $"-applaunch 438100 {arguments}" - }) - ?.Close(); + { + WorkingDirectory = path, + FileName = $"{path}\\steam.exe", + UseShellExecute = false, + Arguments = $"-applaunch 438100 {arguments}" + }) + ?.Close(); return true; } } diff --git a/html/src/app.js b/html/src/app.js index e7901ea3..4229607d 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -11246,27 +11246,44 @@ speechSynthesis.getVoices(); database.addGamelogEventToDatabase(entry); break; case 'vrc-quit': - if (!this.vrcQuitFix || !this.isGameRunning) { + if (!this.isGameRunning) { break; } - var bias = Date.parse(gameLog.dt) + 3000; - if (bias < Date.now()) { - console.log('QuitFix: Bias too low, not killing VRC'); - break; - } - AppApi.QuitGame().then((processCount) => { - if (processCount > 1) { - console.log( - 'QuitFix: More than 1 process running, not killing VRC' - ); - } else if (processCount === 1) { - console.log('QuitFix: Killed VRC'); - } else { - console.log( - 'QuitFix: Nothing to kill, no VRC process running' - ); + if (this.vrcQuitFix) { + var bias = Date.parse(gameLog.dt) + 3000; + if (bias < Date.now()) { + console.log('QuitFix: Bias too low, not killing VRC'); + break; } - }); + AppApi.QuitGame().then((processCount) => { + if (processCount > 1) { + console.log( + 'QuitFix: More than 1 process running, not killing VRC' + ); + } else if (processCount === 1) { + console.log('QuitFix: Killed VRC'); + } else { + console.log( + 'QuitFix: Nothing to kill, no VRC process running' + ); + } + }); + } + if (this.vrcOSCFix) { + setTimeout(() => { + AppApi.KillInstall().then((processKilled) => { + if (processKilled) { + console.log( + 'OSCFix: Killed Install.exe' + ); + } else { + console.log( + 'OSCFix: Nothing to kill, no Install.exe process running' + ); + } + }); + }, 2000); + } break; case 'openvr-init': this.isGameNoVR = false; @@ -15394,6 +15411,10 @@ speechSynthesis.getVoices(); 'VRCX_vrcQuitFix', true ); + $app.data.vrcOSCFix = await configRepository.getBool( + 'VRCX_vrcOSCFix', + true + ); $app.data.vrBackgroundEnabled = await configRepository.getBool( 'VRCX_vrBackgroundEnabled', false @@ -15573,6 +15594,7 @@ speechSynthesis.getVoices(); this.relaunchVRChatAfterCrash ); await configRepository.setBool('VRCX_vrcQuitFix', this.vrcQuitFix); + await configRepository.setBool('VRCX_vrcOSCFix', this.vrcOSCFix); await configRepository.setBool( 'VRCX_vrBackgroundEnabled', this.vrBackgroundEnabled diff --git a/html/src/localization/en/en.json b/html/src/localization/en/en.json index 3c2160f0..a4eab80f 100644 --- a/html/src/localization/en/en.json +++ b/html/src/localization/en/en.json @@ -424,6 +424,10 @@ "header": "VRChat Quit Fix", "description": "Kill VRChat after exiting game" }, + "vrchat_osc_fix": { + "header": "VRChat OSC Fix", + "description": "Kill install process after exiting game" + }, "auto_cache_management": { "header": "Automatically Manage Cache When Closing VRChat", "description": "Auto delete old versions from cache" diff --git a/html/src/mixins/tabs/settings.pug b/html/src/mixins/tabs/settings.pug index a3d721d0..739927d9 100644 --- a/html/src/mixins/tabs/settings.pug +++ b/html/src/mixins/tabs/settings.pug @@ -443,6 +443,11 @@ mixin settingsTab() div.options-container-item span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.vrchat_quit_fix.description') }} el-switch(v-model="vrcQuitFix" @change="saveOpenVROption") + //- Advanced | VRChat OSC Fix + span.sub-header {{ $t('view.settings.advanced.advanced.vrchat_osc_fix.header') }} + div.options-container-item + span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.vrchat_osc_fix.description') }} + el-switch(v-model="vrcOSCFix" @change="saveOpenVROption") //- Advanced | Auto Cache Management span.sub-header {{ $t('view.settings.advanced.advanced.auto_cache_management.header') }} div.options-container-item