Answer the question
In order to leave comments, you need to log in
How to determine that the computer is playing video or graphics on the screen?
I have a reminder program to take a break from the screen.
How can I track for it that a video is playing on the screen or the application is on in full screen?
It's like playing a video in a browser and the computer does not turn off the screen while the video is playing.
Answer the question
In order to leave comments, you need to log in
When an application wants to stop the computer from sleeping, it leaves a request to the system through the PowerCreateRequest function .
It seems impossible to get these requests through the public API, because this API does not exist.
But there is a console utility powercfg, if you run it with the -REQUESTS key, it gives a list of active requests. It requires administrator rights to work. Parsing its output is difficult due to localized strings, but for the utility itself, this is not a problem.
When the video is launched in chrome, it showed me this:
DISPLAY:
[PROCESS] \Device\HarddiskVolume2\Program Files (x86)\Google\Chrome\Application\chrome.exe
Playing video
SYSTEM:
[DRIVER] Realtek High Definition Audio (HDAUDIO\FUNC_01&VEN_10EC&DEV_0887&SUBSYS_1458A002&REV_1003\4&3828eb94&0&0201)
Аудиопоток уже используется.
[PROCESS] \Device\HarddiskVolume2\Program Files (x86)\Google\Chrome\Application\chrome.exe
Playing audio
AWAYMODE:
Нет.
var processStartInfo = new ProcessStartInfo("powercfg.exe", "-REQUESTS")
{
UseShellExecute = false,
RedirectStandardOutput = true
};
var process = Process.Start(processStartInfo);
var data = process.StandardOutput.ReadToEnd();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question