diff --git a/App.xaml.cs b/App.xaml.cs index c0034f9..32d9ce7 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Win32; +using System; using System.Collections.Generic; using System.Configuration; using System.Data; diff --git a/Windows/OverlayWindow.xaml.cs b/Windows/OverlayWindow.xaml.cs index 9457eff..e377230 100644 --- a/Windows/OverlayWindow.xaml.cs +++ b/Windows/OverlayWindow.xaml.cs @@ -27,6 +27,7 @@ using UXTU.Scripts.Adpative_Modes.Performance; using AATUV3.Scripts.SMU_Backend_Scripts; using MessageBox = System.Windows.MessageBox; +using Microsoft.Win32; namespace AATUV3 { @@ -129,10 +130,29 @@ void Adaptive_Tick(object sender, EventArgs e) CpuPowerLimiter.CurveOptimiserLimit(cpuLoad, maxCO); } } + SystemEvents.PowerModeChanged += OnPowerChange; } catch { } } + private void OnPowerChange(object s, PowerModeChangedEventArgs e) + { + switch (e.Mode) + { + case PowerModes.Resume: + // Restart and run as admin + var exeName = Process.GetCurrentProcess().MainModule.FileName; + ProcessStartInfo startInfo = new ProcessStartInfo(exeName); + startInfo.Verb = "runas"; + startInfo.Arguments = "restart"; + Process.Start(startInfo); + this.Close(); + break; + case PowerModes.Suspend: + break; + } + } + public int cpuLoad = 0; void AutoReapply_Tick(object sender, EventArgs e)