Created
September 24, 2020 18:20
-
-
Save exelix11/1012b838eb2318b6c7b646429bde5b8f to your computer and use it in GitHub Desktop.
Sleepless: a simple program to make sure your PC stays awake
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
#include <iostream> | |
#include <windows.h> | |
int main() | |
{ | |
SetConsoleTitleW(L"Sleepless"); | |
if (SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED)) | |
std::cout << "Here, have some coffee." << std::endl << "Press return to quit..."; | |
else | |
{ | |
std::cout << "Couldn't set mode :(" << std::endl; | |
return 1; | |
} | |
while (getchar() != '\n'); | |
std::cout << "Good night :)" << std::endl; | |
SetThreadExecutionState(ES_CONTINUOUS); | |
Sleep(700); | |
return 0; | |
} |
0/10 no cross platform support smh my head do better next time
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build with
cl /O2 /EHsc Sleepless.cpp