Idle state identification on a Windows machine

I know about the GetLastInputInfo method, but this will give me only the duration since the last user input - keyboard or mouse. If the user input was received last 10 minutes ago, this does not mean that the system has been idle for 10 minutes - scanning, loading, movies - there are many reasons.

So, how can we determine if a system is really idle or not?

Does anyone know what the definition of a "idle" window is? There should be a combination of threshold values ​​- for example, less than 5% of the processor, less than 3% of the disk drive, etc. - along with a custom input parameter ... does anyone know the exact definition?

+3
source share
2 answers

Since most Windows applications are controlled by the user interface, and the Windows user interface is controlled by extracting messages from the message queue, one common way to determine when an application is “idle” is when it has no messages in the message queue.

In a Windows application, messages always appear (user-generated and generated by the system), but in a typical application you will see frequent short periods of downtime. When the mouse moves around the window in your application, your downtimes drop to zero until the mouse stops moving, because mouse activity creates a lot of message activity.

, Windows, GetMessage, , PeekMessage. GetMessage , , . PeekMessage true, false, . PeekMessage .

PeekMessage false, "" , .

WinForms Application.Idle event

, , . .

+2

"". , , .

+2

Source: https://habr.com/ru/post/1722351/


All Articles