falahati/NvAPIWrapper

Multiple displays

Closed this issue · 2 comments

Hey, it would be great if we could access the displays that we want to use.
I want to make a little program that will let me change my display between my TV and my three monitors. It's very time consuming and frustrating because sometimes the order of the displays is messed up and I need to go and manually drag the displays to get them in the right order.

var displays = Wrapper.GetConnectedNvidiaGPUDisplays();
Something like Wrapper.SetActiveDisplay(display[0], display[1]);
The others that are not specified in setactivedisplay, example my TV would be deactivated.

It's like the Nvidia Control Panel, on the multiple displays tab. Just like that, but if we could access it by code it would be brilliant.

Wrapper.SetPrimaryDisplay(display[0]);

These are just a few ideas;
The order of the SetActiveDisplay would be the order that they are in real life.

Thank you.

You need to use the NvAPIWrapper.Display.PathInfo.GetDisplaysConfig() method to get the current display arrangement, modify it your liking, and then use the NvAPIWrapper.Display.PathInfo.SetDisplaysConfig() to apply the new arrangement.

The properties you need to change specifically are the PathInfo.Position and PathInfo.IsGDIPrimary. Primary display always has a position of (0,0) and all other displays positions are also required to be changed to be relative to the primary one.
To identify the displays you either need to use their names, their EDID or their connected port to decide. This information is available via the PathInfo.TargetInfo property and specifically at PathTargetInfo.DisplayDevice property.

However, since this library is specific to NVidia graphic cards and what you want to do is not, I suggest using my other library that is capable is doing the same thing but using the standard Windows API:
https://github.com/falahati/WindowsDisplayApi

Steps are similar, you need to use the WindowsDisplayAPI.DisplayConfig.PathInfo.GetActivePaths() static method to get the display configurations, create a new display configuration based on this information and then use the WindowsDisplayAPI.DisplayConfig.PathInfo.ApplyPathInfos() to set the new configuration.

Each display target is a physical device, while a display source means a logical device. For example, you might have a setup with two cloned displays, this means that you have two display target but since both are used to display the same thing, you have only one display source. A path defines the relationship between a display source and one or more display targets.

You can also check my other project here:
https://github.com/falahati/HeliosDisplayManagement

This allows you to switch between two or more profiles relatively fast. It's still under development and some feature might not work as well as it should.

It uses the same libraries but you don't need to write any code.