Skip to content

Instantly share code, notes, and snippets.

@exelix11
Created September 24, 2020 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exelix11/1012b838eb2318b6c7b646429bde5b8f to your computer and use it in GitHub Desktop.
Save exelix11/1012b838eb2318b6c7b646429bde5b8f to your computer and use it in GitHub Desktop.
Sleepless: a simple program to make sure your PC stays awake
#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;
}
@exelix11
Copy link
Author

Build with cl /O2 /EHsc Sleepless.cpp

@bleck9999
Copy link

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