Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I second this. I was looking for a way to set up a hotkey to switch between headphones and speakers and that's how I discovered AHK. Nircmd was the recommended solution and I found some sample scripts that people suggested. From there I made this:
- ;=== Windows Sound Controls ===
- ; Uses Ctrl-Win and a numberpad key:
- ; NP/ Toggle output between speakers and headphones
- ; NP+ Current Volume +5
- ; NP- Current Volume -5
- ; NP* Current Volume mute
- #^NumpadAdd::
- SoundSet,+5
- return
- #^NumpadSub::
- SoundSet,-5
- return
- #^NumpadMult::
- SoundSet,+1,,Mute ; toggle mute
- Return
- ;---------------------------
- #^NumpadDiv::
- audioDeviceToggle:=!audioDeviceToggle ; This toggles the variable between true/false
- if audioDeviceToggle
- {
- Run nircmd setdefaultsounddevice "Speakers"
- soundToggleBox("Speakers")
- }
- else
- {
- Run nircmd setdefaultsounddevice "Realtek HD Audio 2nd Output"
- soundToggleBox("Headphones")
- }
- Return
- ;---------------------------
- ; Display sound toggle GUI
- soundToggleBox(Device)
- {
- IfWinExist, soundToggleWin
- {
- Gui, destroy
- }
- Gui, +ToolWindow -Caption +0x400000 +alwaysontop
- Gui, Add, text, x35 y8, Default sound: %Device%
- SysGet, screenx, 0
- SysGet, screeny, 1
- xpos:=screenx-275
- ypos:=screeny-100
- Gui, Show, NoActivate x%xpos% y%ypos% h30 w200, soundToggleWin
- SetTimer,soundToggleClose, 2000
- }
- soundToggleClose:
- SetTimer,soundToggleClose, off
- Gui, destroy
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement