Last active
April 25, 2021 22:05
-
-
Save jonasbits/6861522 to your computer and use it in GitHub Desktop.
python ctypes.windll.kernel32.SetThreadExecutionState(0x00000002)
http://msdn.microsoft.com/en-us/library/windows/desktop/aa373208(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/aa373233(v=vs.85).aspx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import sys | |
import os | |
import ctypes | |
ES_CONTINUOUS = 0x80000000 | |
ES_AWAYMODE_REQUIRED = 0x00000040 | |
ES_SYSTEM_REQUIRED = 0x00000001 | |
ES_DISPLAY_REQUIRED = 0x00000002 | |
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED) | |
p = ['|', '/', '-', '\\'] | |
os.system('cls') | |
while True: | |
for i in range(0, 4): | |
print('\r' + p[i] + ' Press Ctrl-C to allow computer to sleep', end='') | |
try: | |
time.sleep(2) | |
except(KeyboardInterrupt): | |
print('\nGoodbye') | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
excellent remix @kbarnes3