The script below is not tested, and certainly not in your environment,
but it might help.
I use here three tools:
First download the tools and unpack them into their folders.
Then run AEPC without parameters while all three devices are connected,
and it will list their names. Note down the names, or at least an identifying
sub-string inside the name.
At this point I don't know whether it will list the "Speaker/Headphone" as one
or two devices. If one device, then I assume that the Headphone takes
precedence automatically and the script needs to be shortened.
My script assumes three devices, but their names are only a guess until you run AEPC.
After installing AutoHotKey, put the text below in a .ahk
file and double-click
it to test. You may stop the script by right-click on the green H icon in the
traybar and choosing Exit. To have it run on login, place it in the Startup group at
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
.
Check and replace below the strings used in the
findstr commands:
#Persistent ; prevents the script from exiting when it reaches 'return'
SetTimer, detectDevices, 1000 ; check every second
return
detectDevices: ; this is the timer routine
RunWait, %ComSpec% /c "C:\Temp\AudioEndPointController\Release\EndPointController.exe" | findstr Headphone
if (%ErrorLevel% = 0) { ; found headphone
Run, "C:\Program Files\Nirsoft Package\NirSoft\x64\nircmd.exe" setdefaultsounddevice Headphones
} else {
RunWait, %ComSpec% /c "C:\Temp\AudioEndPointController\Release\EndPointController.exe" | findstr Monitor-device
if (%ErrorLevel% = 0) { ; found monitor device
Run, "C:\Program Files\Nirsoft Package\NirSoft\x64\nircmd.exe" setdefaultsounddevice Monitor-name
} else { ; only speaker is left
Run, "C:\Program Files\Nirsoft Package\NirSoft\x64\nircmd.exe" setdefaultsounddevice Speaker
}
}
Return ; end of timer routine