Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Lib/v2/AHK_Common.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment on lines +43 to +51

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and to adhere to modern AutoHotkey v2 style, consider using StrSplit() instead of the legacy Loop Parse. StrSplit() is generally preferred in AHK v2 for its clarity.

    for _, p_raw in StrSplit(EnvGet("PATH"), ";")
    {
        p := Trim(p_raw)
        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 = ""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check if exe = "" can be simplified. In AutoHotkey v2, you can check for an empty string using if !exe. This is more concise and idiomatic.

    if !exe

{
Comment on lines +60 to +61
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opening brace should be on the same line as the if statement to follow OTBS (One True Brace Style) convention used throughout the codebase. For example, see Lib/v2/WindowManager.ahk:11 where if hasTitle { follows OTBS, and line 72 where if saved.Has(id) { also follows OTBS.

Copilot generated this review using guidance from repository custom instructions.
MsgBox("Required executable not found: " . name . "`nChecked PATH and fallbacks.")
ExitApp(1)
}
return exe
}
26 changes: 0 additions & 26 deletions Other/playnite-all.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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 . " <mode>`n`nModes:`n fullscreen`n tv`n tv_firefox`n tv_sound")
ExitApp(1)
Expand Down
28 changes: 14 additions & 14 deletions ahk/Minecraft/MC_Bedrock.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 != "") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The check if (svv != "") can be simplified. In AutoHotkey v2, you can directly check the truthiness of the variable. Using if svv is more concise and idiomatic for checking if a string is not empty.

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
}
}
Loading