#include ; for _DebugArrayDisplay() #include "SetMicForPlayback.bulk.au3" ;~ Global $g_aEnumerateAudioDevices = _EnumerateAudioDevices() ;~ Global $g_aEnumerateAudioDevicesWas = $g_aEnumerateAudioDevices ;~ _DebugArrayDisplay($g_aEnumerateAudioDevicesWas, "$g_aEnumerateAudioDevicesWas") ;~ Row |Col 0 |Col 1 |Col 2 |Col 3 |Col 4 ;~ Row 0 |Playback |{34d90035-0679-4b97-b868-ddba418b989b} |{0.0.0.00000000}.{34d90035-0679-4b97-b868-ddba418b989b}|Speakers (High Definition Audio Device) |1 ;~ Row 1 |Playback |{43d508ee-19c5-4513-bd52-e1b7ba57ee82} |{0.0.0.00000000}.{43d508ee-19c5-4513-bd52-e1b7ba57ee82}|Headset Earphone (2- Arctis Pro Wireless Chat) |0 ;~ Row 2 |Playback |{a6f69bc4-f708-4a0f-bf58-995fe9d5d221} |{0.0.0.00000000}.{a6f69bc4-f708-4a0f-bf58-995fe9d5d221}|Headset Earphone (Corsair VOID Wireless Gaming Dongle) |0 ;~ Row 3 |Microphone |{a025c7e9-3655-474f-9643-8f05f1e4d591} |{0.0.1.00000000}.{a025c7e9-3655-474f-9643-8f05f1e4d591}|Headset Microphone (2- Arctis Pro Wireless Chat) |0 ;~ Row 4 |Microphone |{f9a630d2-44e9-4db5-b115-9fe7503a2ec7} |{0.0.1.00000000}.{f9a630d2-44e9-4db5-b115-9fe7503a2ec7}|Headset Microphone (Corsair VOID Wireless Gaming Dongle) |1 ;~ _SwitchToDevice($g_aEnumerateAudioDevices[4][2]) ;~ + [1]"OnDefaultDeviceChanged", [2]"0", [3]"1", [4]"{0.0.0.00000000}.{43d508ee-19c5-4513-bd52-e1b7ba57ee82}" ;~ + [1]"OnDefaultDeviceChanged", [2]"0", [3]"1", [4]"{0.0.0.00000000}.{34d90035-0679-4b97-b868-ddba418b989b}" main() Func main() If WinExists(StringTrimRight(@ScriptName, 4) & "'s hidden window") Then Exit 0 AutoItWinSetTitle(StringTrimRight(@ScriptName, 4) & "'s hidden window") Local $n, $a, $s, $b, $i While Sleep(50) If $g_aAudioSwitched[0] And TimerDiff($g_aAudioSwitched[0]) > 500 Then ConsoleWrite('+ [1]"' & $g_aAudioSwitched[1] & '", [2]"' & $g_aAudioSwitched[2] & '", [3]"' & $g_aAudioSwitched[3] & '", [4]"' & $g_aAudioSwitched[4] & '"' & @CRLF) Switch $g_aAudioSwitched[1] Case "OnDefaultDeviceChanged" $s = "" $a = _EnumerateAudioDevices() For $n = 0 To UBound($a) - 1 If $a[$n][2] = $g_aAudioSwitched[4] Then $b = StringSplit($a[$n][3], "()", 0) If UBound($b) > 2 Then $s = $b[2] ConsoleWrite($s & @CRLF) ExitLoop EndIf Next If $s = "" Then ConsoleWrite(@TAB & $s & ' = not found ?, just 1 device ?, remote audio ?' & @CRLF) Else $i = 5 For $n = 0 To UBound($a) - 1 If $a[$n][0] = "Microphone" Then If StringInStr($a[$n][3], $s) Then ; ObjCreateInterface: "Warning: This feature is experimental." $i = ShellExecuteWait(@ScriptFullPath, "/ErrorStdOut " & $a[$n][2], @ScriptDir) Switch $i Case 3 ConsoleWrite(@TAB & $s & ": apply = True" & @CRLF) Case 4 ConsoleWrite(@TAB & $s & ": apply = False" & @CRLF) Case 1 ConsoleWrite(@TAB & $s & ": apply = Crashed" & @CRLF) Case Else ConsoleWrite(@TAB & $s & ": no clue !" & @CRLF) EndSwitch ExitLoop EndIf Else ContinueLoop EndIf Next EndIf If $i = 5 Then ConsoleWrite(@TAB & $s & ' = ..have to code a "default mic" if none associated. ( you do it, I don''t have one. )' & @CRLF) ;~ AdlibRegister("did_it_work") ; ...to have some feedback while in development, but the "Sound"("Recording" tab), shows the change on the fly. Case Else ConsoleWrite("! no code written for this event" & @CRLF) EndSwitch $g_aAudioSwitched[0] = 0 $g_aAudioSwitched[1] = "" EndIf WEnd EndFunc ;==>main Func did_it_work() AdlibUnRegister("did_it_work") Local $a = _EnumerateAudioDevices() _DebugArrayDisplay($a, "_EnumerateAudioDevices()") EndFunc ;==>did_it_work