i know this is old, mine is a console program
class Program { [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] static extern uint SetThreadExecutionState(EXECUTION_STATE esFlags); public const uint ES_CONTINUOUS = 0x80000000; public const uint ES_SYSTEM_REQUIRED = 0x00000001; ####then call this below code public static void keepalive() { int x = 0; for(; ; ) { x++; SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); Console.WriteLine("Preventing lock screen.... disabling proxy"); setProxy("", false); Thread.Sleep(10000); if (x == 10) { x = 0; Console.Clear(); } } }