Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if monitor is on c#

Tags:

c#

Is it possible to detect if the users monitor is turned on using c#?

like image 760
Steven Avatar asked Oct 12 '10 09:10

Steven


People also ask

How can I tell which monitor is using my graphics card?

Beneath Multiple displays, click Advanced display settings. It's possible to have different graphics cards connected to different monitors. If necessary, use the dropdown to select your primary monitor. Beneath Display information, it will show which graphics card you're Connected to for that monitor.

How do you detect displays?

Select Start , then open Settings . Under System , select Display . Your PC should automatically detect your monitors and show your desktop. If you don't see the monitors, select Multiple displays , then Detect.

What is USB Display?

USB graphics technology allows smooth video playback and provides a low latency connection that feels very much like a traditional monitor while providing "plug and display" simplicity. USB graphics technology allows for high resolution, full 32-bit color graphics.


2 Answers

WMI might help.

In Vista+, there is the WmiMonitorBasicDisplayParams class, where the "Active" property tells you if the display is active.

Here's an example which works for me:

using System.Management;

// ...

var query = "select * from WmiMonitorBasicDisplayParams";
using(var wmiSearcher = new ManagementObjectSearcher("\\root\\wmi", query))
{
    var results = wmiSearcher.Get();
    foreach (ManagementObject wmiObj in results)
    {
        // get the "Active" property and cast to a boolean, which should 
        // tell us if the display is active. I've interpreted this to mean "on"
        var active = (Boolean)wmiObj["Active"];
    }
}
like image 127
codekaizen Avatar answered Oct 06 '22 15:10

codekaizen


All the Active property does is tell you if Windows is using the display or not. Also DVI/HDMI will report a connection even when the display is turned off. In short, there is no method for checking other than something homemade--like hooking up a light sensor or webcam and pointing it at the monitor's power light :)

like image 37
dynamichael Avatar answered Oct 06 '22 15:10

dynamichael