简体   繁体   中英

How To Invoke a Method While Turn off the Monitor as well as Turn on the Monitor by pressing button on monitor

I want To Invoke the Following Method while Turn off the Monitor

    Stopwatch sw =new Stopwatch();        
    sw.Stop();

also i want to invoke the following Method while Turn on the Monitor

    sw.Start(); 

Is there any possible way to do this in c#?

Turning off monitor is completely different from operating system function. In a windows system it shows just the output given by the System. It does not take any input to the system. So you cannot add any functionality to your program using the power button of the monitor. If the monitor turns off automatically by the power management system you can trigger events but not by pressing power button of monitor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM