Quantcast
Channel: Change device controlled by volume keys without changing default - Super User
Viewing all articles
Browse latest Browse all 8

Answer by astrovan for Change device controlled by volume keys without changing default

$
0
0

I updated qwertymodo's code for AutoHotkey v2.

You can directly use the name of the audio device from windows, with or without the elements in parentheses. For example, this means you can replace the number 7 with "Speakers" or "Speakers (Realtek(R) Audio)". Leaving ComponentID as a blank string for v2 gives the same result as setting it to MASTER as before.

This first code is a direct translation from v1 to v2.

#Requires AutoHotkey v2.0; Use the Soundcard Analysis script found here to set these parameters; https://www.autohotkey.com/docs/v2/lib/Sound.htm#ExSoundcardDeviceNumber := 7ComponentID := ""Volume_Up::{SoundSetVolume("+2", ComponentID, DeviceNumber)}Volume_Down::{SoundSetVolume(-2, ComponentID, DeviceNumber)}Volume_Mute::{SoundSetMute(-1, ComponentID, DeviceNumber)}

This second code is for devices that don't work with standard mute.

#Requires AutoHotkey v2.0; Use the Soundcard Analysis script found here to set these parameters; https://www.autohotkey.com/docs/v2/lib/Sound.htm#ExSoundcardDeviceNumber := 7ComponentID := ""savedVol :=  0Volume_Up::{SoundSetVolume("+2", ComponentID, DeviceNumber)}Volume_Down::{SoundSetVolume(-2, ComponentID, DeviceNumber)}Volume_Mute::{global savedVolcurrentVol := SoundGetVolume(ComponentID, DeviceNumber)if (currentVol > 0){savedVol := currentVolSoundSetVolume(0, ComponentID, DeviceNumber)} else{SoundSetVolume(savedVol, ComponentID, DeviceNumber)}}

Viewing all articles
Browse latest Browse all 8

Trending Articles