Prevent Windows from going to sleep while Flowframes is running (needs testing)

This commit is contained in:
n00mkrad
2022-05-01 22:26:53 +02:00
parent 4108875e0b
commit 39800e48b9

View File

@@ -16,6 +16,7 @@ using Microsoft.WindowsAPICodePack.Taskbar;
using Flowframes.MiscUtils;
using System.Threading.Tasks;
using System.Linq;
using System.Runtime.InteropServices;
#pragma warning disable IDE1006
@@ -23,6 +24,11 @@ namespace Flowframes
{
public partial class Form1 : Form
{
[Flags]
public enum EXECUTION_STATE : uint { ES_AWAYMODE_REQUIRED = 0x00000040, ES_CONTINUOUS = 0x80000000, ES_DISPLAY_REQUIRED = 0x00000002, ES_SYSTEM_REQUIRED = 0x00000001 }
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags); // PREVENT WINDOWS FROM GOING TO SLEEP
public bool initialized = false;
public bool quickSettingsInitialized = false;