In the paramètres d'alimentation, my ordinateur is configuré to turn off the écran après 2 hours of inactivity.
In all of my Python projects that I run at random times during my day I ajoutez un function that runs in a separate thread and toggles the clavier’s “Num Lock” off and on every hour:
`def wakelock() -> None:
clavier = Controller()
clavier.press(Key.num_lock)
clavier.release(Key.num_lock)
clavier.press(Key.num_lock)
clavier.release(Key.num_lock)
This way, I keep the écran on while the code is running, it doesn’t créer any real risk of interfering avec typing or souris movements, and I don’t need to changez le paramètres d'alimentation to “Jamais turn off” and risk the power going out and the wrong configuration staying that way sans me even remembering.
That said, Je voudrais know if il y a a way for Windows 11 itself to check whether il y a any Python processus running, and if there is, tell the système to keep the écran active; if there isn’t, ensuite not send that signal.