Sleep Fix

This commit is contained in:
Serge
2023-05-21 19:19:26 +02:00
parent 1e0169a71d
commit ac60986646
2 changed files with 15 additions and 7 deletions

View File

@@ -121,16 +121,18 @@ namespace GHelper
}
}
static void TabletMode()
static bool GetTouchpadState()
{
bool touchpadState, tabletState;
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
{
touchpadState = (key?.GetValue("Enabled")?.ToString() == "1");
return (key?.GetValue("Enabled")?.ToString() == "1");
}
}
tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
static void TabletMode()
{
bool touchpadState = GetTouchpadState();
bool tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState);
@@ -192,11 +194,13 @@ namespace GHelper
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessUp);
break;
case 107: // FN+F10
bool touchpadState = GetTouchpadState();
AsusUSB.TouchpadToggle();
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Touchpad", ToastIcon.Touchpad);
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad);
break;
case 108: // FN+F11
Application.SetSuspendState(PowerState.Suspend, true, true);
Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x6c, "Sleep");
//NativeMethods.SetSuspendState(false, true, true);
break;
}
}

View File

@@ -435,6 +435,10 @@ public class NativeMethods
}
[DllImport("Powrprof.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool SetSuspendState(bool hiberate, bool forceCritical, bool disableWakeEvent);
public const int KEYEVENTF_EXTENDEDKEY = 1;
public const int KEYEVENTF_KEYUP = 2;