SaifAqqad / VMR.ahk

AutoHotkey wrapper class for Voicemeeter's Remote API
https://saifaqqad.github.io/VMR.ahk/
39 stars 3 forks source link

only hotkeys working with voicemeeter focus are volume up and down and mute #25

Open NeonLightning opened 2 months ago

NeonLightning commented 2 months ago
#Requires AutoHotkey v2
#include VMR.ahk
voicemeeter := VMR().Login()
/*
voicemeeter controls
*/
Volume_Mute::{
    voicemeeter.Strip[6].mute := -1
    voicemeeter.Strip[7].mute := -1
    voicemeeter.Strip[8].mute := -1
    if is_muted := voicemeeter.Strip[6].mute
        DisplayOsd("UnMuted", 1000)
    else
        DisplayOsd("Muted", 1000)
}
F23::{
    if (voicemeeter.Strip[6].A1 == 1) {
        DisplayOsd("Headphones", 1000)
        voicemeeter.Strip[6].A2 := true
        voicemeeter.Strip[7].A2 := true
        voicemeeter.Strip[8].A2 := true
        voicemeeter.Strip[6].A1 := false
        voicemeeter.Strip[7].A1 := false
        voicemeeter.Strip[8].A1 := false
    } else {
        DisplayOsd("Speakers", 1000)
        voicemeeter.Strip[6].A2 := false
        voicemeeter.Strip[7].A2 := false
        voicemeeter.Strip[8].A2 := false
        voicemeeter.Strip[6].A1 := true
        voicemeeter.Strip[7].A1 := true
        voicemeeter.Strip[8].A1 := true
    }
}
F24::{
    if (voicemeeter.Strip[6].A3 == 1) {
        DisplayOsd("TV off", 1000)
        voicemeeter.Strip[6].A3 := false
        voicemeeter.Strip[7].A3 := false
        voicemeeter.Strip[8].A3 := false
    } else {
        DisplayOsd("TV on", 1000)
        voicemeeter.Strip[6].A3 := true
        voicemeeter.Strip[7].A3 := true
        voicemeeter.Strip[8].A3 := true
    }
}
F16 & Volume_Up::{
    voicemeeter.Bus[1].Increment("gain", 1).Then(gain => DisplayBusVol(1, gain))
    voicemeeter.Bus[2].Increment("gain", 1).Then(gain => DisplayBusVol(2, gain))
    voicemeeter.Bus[3].Increment("gain", 1).Then(gain => DisplayBusVol(3, gain))
}
F16 & Volume_Down::{
    voicemeeter.Bus[1].Increment("gain", -1).Then(gain => DisplayBusVol(1, gain))
    voicemeeter.Bus[2].Increment("gain", -1).Then(gain => DisplayBusVol(2, gain))
    voicemeeter.Bus[3].Increment("gain", -1).Then(gain => DisplayBusVol(3, gain))
}
DisplayBusVol(*) {
    SetTimer () => DisplayOsd(
        "Gain: " voicemeeter.Bus[1].gain
        "," voicemeeter.Bus[2].gain
        "," voicemeeter.Bus[3].gain,
        500
    ), -100
}
Volume_Down::{
    voicemeeter.Strip[6].Increment("gain", -1).Then(gain => DisplayVol(6, gain))
    voicemeeter.Strip[7].Increment("gain", -1).Then(gain => DisplayVol(7, gain))
    voicemeeter.Strip[8].Increment("gain", -1).Then(gain => DisplayVol(8, gain))
}
Volume_Up::{
    voicemeeter.Strip[6].Increment("gain", 1).Then(gain => DisplayVol(6, gain))
    voicemeeter.Strip[7].Increment("gain", 1).Then(gain => DisplayVol(7, gain))
    voicemeeter.Strip[8].Increment("gain", 1).Then(gain => DisplayVol(8, gain))
}
DisplayVol(*) {
    SetTimer () => DisplayOsd(
        "Gain: " voicemeeter.Strip[6].gain
        "," voicemeeter.Strip[7].gain
        "," voicemeeter.Strip[8].gain,
        500
    ), -100
}
DisplayOsd(text, timeout) {
        textColor := "d400cd"
        bgColor := "000000"
        g := Gui("+AlwaysOnTop +ToolWindow +E0x20 -Caption -SysMenu -Owner", "OSD")
        g.BackColor := bgColor
        g.SetFont "s16", "fixedsys"
        g.AddText "x10 y10 h40 c" textColor, text
        g.Show "NoActivate x10 y10 h35"
        SetTimer () => g.Destroy(), -Abs(timeout)
}
SaifAqqad commented 2 months ago

I just tested your script, and it seems to work ok, I had to change the hotkeys though since I don't have an F23/F24 key on my keyboard

https://github.com/SaifAqqad/VMR.ahk/assets/47293197/c94760d2-b489-41a5-b17d-7e71712d0b57

Maybe it's an issue with a conflicting hotkey in another app?

NeonLightning commented 2 months ago

hrm odd. no i don't have anything else using my extra fkeys. thanks for looking into it though. probably just some wonkey issue with my system.(it's not in a happy state)