-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor MC_Bedrock to use dynamic path for SoundVolumeView #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = "" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| { | ||
|
Comment on lines
+60
to
+61
|
||
| MsgBox("Required executable not found: " . name . "`nChecked PATH and fallbacks.") | ||
| ExitApp(1) | ||
| } | ||
| return exe | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 != "") { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| 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 | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better readability and to adhere to modern AutoHotkey v2 style, consider using
StrSplit()instead of the legacyLoop Parse.StrSplit()is generally preferred in AHK v2 for its clarity.