Hi, I wrote a couple of scripts to switch screen and speakers from my monitor/Bluetooth speaker to a TV/speakers in an adjoining room. Here are the scripts.
The first one redirects the visual and audio signal to the TV
Displayswitch.exe /external
$device1 = “Sony TV” $device2 = “Speakers”
$Audio = Get-AudioDevice -playback Write-Output "Audio device was " $Audio.Name Write-Output "Audio device now set to "
if ($Audio.Name.StartsWith($device1)) { (Get-AudioDevice -list | Where-Object Name -like ("$device2*") | Set-AudioDevice).Name } Else { (Get-AudioDevice -list | Where-Object Name -like ("$device1*") | Set-AudioDevice).Name }
The second one loads Emulationstation, waits until it closes then switches the output back to the computer monitor.
Start-Process “path to” Emulationstation.exe
Wait-Process -Name Emulationstation -ErrorAction SilentlyContinue
Displayswitch.exe /Internal
All good so far. Click the icon (monitors swap) click the second icon and play. The script resets everything when I exit Emulationstation.
So what’s the problem you ask? Well when I combine the scripts into a single script the sound does not transfer to the TV. Can anyone give me any tips as to why?