-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Auto Audio Switcher currently keys the monitor => playback device map using the display names (e.g. "DELL S32WHATEVER") which means if you have multiple monitors with the same name, it won't be possible to select different playback devices for them. (The latter also use their names, but unlike monitors, those can be easily changed in the Sounds control panel.)
Hopefully this is low impact, as I wouldn't expect someone with side-by-side identical monitors to want their playback device to change every time they switched from the left screen to the right screen and back, but on the other hand everyone has different setups, and display manufacturers aren't required to give their monitors good names (as evidenced by literally all monitor names, but more to the point: you might have a monitor on your desk plus a big one for movies that both show up as "LG Display" or something), or for that matter any names at all (in which case they'd probably appear as "Generic PnP Monitor").
Unfortunately, there doesn't seem to be any way to get the display numbers shown in the control panel / settings app. GDI device names (e.g. "\\.\DISPLAY1") look related, but those numbers won't necessarily match the control panel. It's possible the control panel orders the displays by some unknown identifier and then numbers them using their positions within that list.
We could use the GDI names regardless, for example by appending them to the display name (e.g. "DELL S32WHATEVER (\\.\DISPLAY1)"), but it's not clear if those device names are considered stable or not; that is, can they change after a reboot, or by unplugging a monitor and plugging it back in?
Alternatively, it's possible to get a monitor's serial number... or something resembling a serial number using WMI. This still relies on manufacturers setting them to unique values, though (not sure if that's a safe assumption or not), and if displays are showing up as "Generic PnP Monitor", I'd imagine these would be empty:
Get-WmiObject -Namespace "root\WMI" -Class "WMIMonitorID" | % { @{
UserFriendlyName = [System.Text.Encoding]::ASCII.GetString($_.UserFriendlyName)
ManufacturerName = [System.Text.Encoding]::ASCII.GetString($_.ManufacturerName)
ProductCodeID = [System.Text.Encoding]::ASCII.GetString($_.ProductCodeID)
SerialNumberID = [System.Text.Encoding]::ASCII.GetString($_.SerialNumberID)
} }I don't currently have multiple identical monitors to test with, which makes it hard to determine what Windows will do and figure out the best approach. Rather than blindly implement a solution that might not work in practice, I'm going to leave this open for discussion.
Note: Supposedly it's possible to rename devices by editing the registry, but I suspect this will only change the name returned by the older EnumDisplayDevices API and not QueryDisplayConfig which this app uses. The latter has the actual display names shown in the settings app, while the former returns "Generic PnP Monitor" unless you have drivers installed for those specific monitors. Both of my monitors show as that in the device manager, hence my suspicion; however I have not tested it.