Last active
September 22, 2021 14:00
-
-
Save sgqy/37653e1c50fefe20d34852348397e2fc to your computer and use it in GitHub Desktop.
Keep Windows screen on, no mater what weird-and-hidden power configs it uses.
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
#define WIN32_LEAN_AND_MEAN | |
#include <Windows.h> | |
#ifdef MB_DEBUG | |
#define INTERVAL (500) | |
#else | |
#define INTERVAL (30 * 1000) | |
#endif | |
#ifdef MB_DEBUG | |
void __cdecl popup_num(const DWORD val) | |
{ | |
wchar_t msg[300] = { 0 }; | |
wsprintfW(msg, L"%08X", val); | |
MessageBoxW(0, msg, L"", MB_OK); | |
} | |
#endif | |
int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int cmdShow) | |
{ | |
while(TRUE) | |
{ | |
EXECUTION_STATE esRet = SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_AWAYMODE_REQUIRED); | |
#ifdef MB_DEBUG | |
popup_num(esRet); | |
#endif | |
Sleep(INTERVAL); | |
} | |
SetThreadExecutionState(ES_CONTINUOUS); | |
return 0; | |
} |
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
#CC_DEFS = /DMB_DEBUG | |
CC_ARGS = /nologo /utf-8 /c /W3 /Ox /Zo- /GL /MT | |
LD_ARGS = /nologo /ltcg | |
LD_LIBS = user32.lib | |
all: awake.exe | |
awake.exe: awake.obj | |
link $(LD_ARGS) /out:$@ $** $(LD_LIBS) | |
awake.obj: awake.c | |
cl $(CC_ARGS) $(CC_DEFS) /Fo$@ $** | |
.PHONY: run | |
run: awake.exe | |
start "" /d C: /low $** | |
.PHONY: clean | |
clean: | |
del /f awake.obj | |
del /f awake.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment