How to reset system idle timer in Windows 11 (SetThreadExecutionState(ES_SYSTEM_REQUIRED) doesn't work)

405 views Asked by At

Earlier, when we call SetThreadExecutionState(ES_SYSTEM_REQUIRED) without ES_CONTINUOUS, it reset the system idle timer. But in Windows 11, that doesn't work anymore.

I need the reset the idle timer, and I wonder, how can I do it now?

1

There are 1 answers

1
Jeaninez - MSFT On

According to the Doc:System Sleep Criteria

To maintain the time since the last user input, the system uses a display idle timer and a system idle timer. The system compares the idle timers to the values configured in the power plan. If the display idle timer value is greater than the display time-out value, and no threads have requested the display by calling SetThreadExecutionState with ES_DISPLAY_REQUIRED, the system powers off the display. Similarly, if the system idle timer is greater than the system time-out value and no applications have requested the system by calling SetThreadExecutionState with ES_SYSTEM_REQUIRED, the system enters sleep.

When you clear ES_SYSTEM_REQUIRED flag, will allow the system to idle to sleep normally. If the system idle timer is greater than the system time-out value and without ES_SYSTEM_REQUIRED flag, the system enters sleep.