Skip to content

Instantly share code, notes, and snippets.

@EntranceJew
Created June 27, 2018 01:20
Show Gist options
  • Save EntranceJew/c2bc96a553d218b76e48e0eb924655c2 to your computer and use it in GitHub Desktop.
Save EntranceJew/c2bc96a553d218b76e48e0eb924655c2 to your computer and use it in GitHub Desktop.
I wrote an AutoHotkey script to toggle "Listen to this device" for all windows recording devices, because hot-plugging certain USB devices doesn't reset Windows' loopbacks.
; Y'all want a pringle say fuck that.
; For this to work you need to have the audio mixer be the first thing to the right of the system tray hidden icons.
SetKeyDelay, 78, 45
; Open "Sound" window.
; WinActivate, ahk_class Shell_TrayWnd
Send, {LWin Down}{b}{LWin Up}
Sleep, 33
Send, {Right}
Sleep, 33
Send, {AppsKey}
Sleep, 33
Send, {s}
Sleep, 330
WinActivate, Sound ahk_class #32770
WinWaitActive, Sound ahk_class #32770
; Get to Recording tab.
Send, {RControl Down}{PgUp}{RControl Up}
Sleep, 33
Send, {Down}{PgDn}
BreakFree := false
ThisWindow := ""
OldWindow := "bah"
while (ThisWindow != OldWindow) {
; Open the properties window
Send, {LAlt Down}{p}{LAlt Up}
Sleep, 330
WinWaitActive, ahk_class #32770, Properties
OldWindow := ThisWindow
WinGetTitle, ThisWindow, ahk_class #32770
if( ThisWindow = OldWindow or ThisWindow = ""){
BreakFree := true
} else {
; WinActivate, VAC3 Guests Properties ahk_class #32770
; Get to the "Listen" tab.
Send, {RControl Down}{PgDn}{RControl Up}
Sleep, 33
; Toggle "Listen to this device".
Send, {Space}
Sleep, 33
; Apply
Send, {LAlt Down}{p}{LAlt Up}
Sleep, 33
; Re-toggle "Listen to this device".
Send, {Space}
Sleep, 33
; Re-apply
Send, {LAlt Down}{p}{LAlt Up}
Sleep, 33
; Close
Send, {Escape}
Sleep, 33
; Advance upwards.
Send, {Up}
Sleep, 33
}
}
; Close out of this properties and close out of everything
Send, {Escape}
Send, {Escape}
@Hypernovadragon
Copy link

Hypernovadragon commented Mar 25, 2019

I made it so you don't have to have the sound right next to your system tray icons and change the default microphone instead of the lowest one on the list.

; Y'all want a pringle say fuck that.
; For this to work you DON'T need to have the audio mixer be the first thing to the right of the system tray hidden icons.

SetKeyDelay, 78, 45

Run, c:\windows\system32\control.exe mmsys.cpl`,`,1
WinActivate, Sound ahk_class #32770
WinWaitActive, Sound ahk_class #32770
Sleep, 33
Send, {Down}

BreakFree := false
ThisWindow := ""
OldWindow := "bah"

while (ThisWindow != OldWindow) {
; Open the properties window
Send, {LAlt Down}{p}{LAlt Up}
Sleep, 330
WinWaitActive, ahk_class #32770, Properties

OldWindow := ThisWindow
WinGetTitle, ThisWindow, ahk_class #32770
if( ThisWindow = OldWindow or ThisWindow = ""){
	BreakFree := true
} else {
	; WinActivate, VAC3 Guests Properties ahk_class #32770
	; Get to the "Listen" tab.
	Send, {RControl Down}{PgDn}{RControl Up}
	Sleep, 33
	; Toggle "Listen to this device".
	Send, {Space}
	Sleep, 33
	; Apply
	Send, {Enter}
	Sleep, 33
	Sleep, 33
	; Advance upwards.
	Send, {Up}
	Sleep, 33
}
}

; Close out of this properties and close out of everything
Send, {Escape}
Send, {Escape} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment