From 90e1aa7b5ef8b8a67bf639caae8eda2cde040e4d Mon Sep 17 00:00:00 2001 From: Ven0m0 <82972344+Ven0m0@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:47:35 +0000 Subject: [PATCH] Refactor MC_Bedrock to use dynamic path for SoundVolumeView Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- Lib/v2/AHK_Common.ahk | 28 ++++++++++++++++++++++++++++ Other/playnite-all.ahk | 26 -------------------------- ahk/Minecraft/MC_Bedrock.ahk | 28 ++++++++++++++-------------- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/Lib/v2/AHK_Common.ahk b/Lib/v2/AHK_Common.ahk index 3992693..9f2a451 100644 --- a/Lib/v2/AHK_Common.ahk +++ b/Lib/v2/AHK_Common.ahk @@ -36,3 +36,31 @@ InitScript(requireUIA := true, requireAdmin := false, optimize := true) { if optimize SetOptimalPerformance() } + +FindExe(name, fallbacks := []) { + if FileExist(name) + return name + Loop Parse, EnvGet("PATH"), ";" + { + p := Trim(A_LoopField) + if !p + continue + cand := p . "\" . name + if FileExist(cand) + return cand + } + for _, fb in fallbacks + if FileExist(fb) + return fb + return "" +} + +MustGetExe(name, fallbacks := []) { + exe := FindExe(name, fallbacks) + if exe = "" + { + MsgBox("Required executable not found: " . name . "`nChecked PATH and fallbacks.") + ExitApp(1) + } + return exe +} diff --git a/Other/playnite-all.ahk b/Other/playnite-all.ahk index bbbc0ea..5a45412 100644 --- a/Other/playnite-all.ahk +++ b/Other/playnite-all.ahk @@ -12,32 +12,6 @@ InitScript(false, false, true) #SingleInstance Force -FindExe(name, fallbacks := []) { - if FileExist(name) - return name - Loop Parse, EnvGet("PATH"), ";" - { - p := Trim(A_LoopField) - if !p - continue - cand := p . "\" . name - if FileExist(cand) - return cand - } - for _, fb in fallbacks - if FileExist(fb) - return fb - return "" -} -MustGetExe(name, fallbacks := []) { - exe := FindExe(name, fallbacks) - if exe = "" - { - MsgBox("Required executable not found: " . name . "`nChecked PATH and fallbacks.") - ExitApp(1) - } - return exe -} ShowHelp() { MsgBox("Usage:`n " . A_ScriptName . " `n`nModes:`n fullscreen`n tv`n tv_firefox`n tv_sound") ExitApp(1) diff --git a/ahk/Minecraft/MC_Bedrock.ahk b/ahk/Minecraft/MC_Bedrock.ahk index 8df6427..bb7c09c 100644 --- a/ahk/Minecraft/MC_Bedrock.ahk +++ b/ahk/Minecraft/MC_Bedrock.ahk @@ -2,11 +2,7 @@ ; ============================================================================ ; MC_Bedrock.ahk - Minecraft Bedrock Edition launcher with audio setup -; Version: 2.0.0 (Migrated to AHK v2) -; -; WARNING: This script contains hardcoded paths that need customization: -; - ToolDir variable points to specific user directory -; - Adjust paths before use +; Version: 2.1.0 (Migrated to AHK v2) ; ============================================================================ #Include %A_ScriptDir%\..\..\Lib\v2\AHK_Common.ahk @@ -15,19 +11,23 @@ InitScript(false, false, true) #SingleInstance Force Persistent -; TODO: Update this path to match your system -; Original: C:\Users\janni\OneDrive\Backup\Optimal\Scripts\Other\Playnite\Playnite Fullscreen -ToolDir := A_ScriptDir . "\..\..\Other\Playnite_fullscreen" +; Locate SoundVolumeView +svv := FindExe("SoundVolumeView.exe", [ + A_ScriptDir . "\..\..\Other\SoundVolumeView\SoundVolumeView.exe", + A_ScriptDir . "\..\..\Other\Playnite_fullscreen\SoundVolumeView\SoundVolumeView.exe" +]) ; Launch Minecraft Bedrock Edition Run("shell:AppsFolder\Microsoft.MinecraftUWP_8wekyb3d8bbwe!App") DllCall("kernel32.dll\Sleep", "UInt", 250) ; Set default audio devices (requires SoundVolumeView) -try { - RunWait(ToolDir . "\SoundVolumeView\SoundVolumeView.exe /SetDefault `"THX Spatial - Synapse`"") - DllCall("kernel32.dll\Sleep", "UInt", 250) - RunWait(ToolDir . "\SoundVolumeView\SoundVolumeView.exe /SetDefault `"Razer Audio Controller - Game`"") -} catch Error as err { - ; SoundVolumeView not found or error - continue anyway +if (svv != "") { + try { + RunWait(svv . ' /SetDefault "THX Spatial - Synapse"') + DllCall("kernel32.dll\Sleep", "UInt", 250) + RunWait(svv . ' /SetDefault "Razer Audio Controller - Game"') + } catch Error as err { + ; Error executing SoundVolumeView - continue anyway + } }