Event-driven · no polling loop
A power request, not a background loop.
StayGreen holds a Windows power request — created with
PowerCreateRequest and set with
PowerSetRequest — to ask Windows
directly for the awake state. No fake mouse movement, no periodic wake pings, and no loop burning cycles to
pretend the user is active.
It deliberately does not use the older
SetThreadExecutionState flag,
which is thread-affine: the flag belongs to the thread that set it. StayGreen changes its awake state from
several threads — the command handler, the timed-session task, and the Win32 event worker — and a thread-affine
flag produced inconsistent releases. The request API does not have that problem.
-
No polling loop: a foreground event hook, and one scheduled wake per timed session
-
No synthetic input events to trigger EDR or policy suspicion
-
No administrator rights, and no power plan or policy is modified