Python – Prevent Screen Sleep and Screensaver

email me

Modifying the SetThreadExecutionState will allow you to control whether or not the computer will idle—no idle, no monitor sleep or screensaver.

import ctypes
ctypes.windll.kernel32.SetThreadExecutionState(0x80000002)
input('{Press enter to exit}')
ctypes.windll.kernel32.SetThreadExecutionState(0x80000000)


Python Terminal

 

Notes

SetThreadExecutionState function

 

tags: MrNetTek