This commit is contained in:
Serge
2024-04-01 14:22:29 +02:00
parent 351566e24a
commit 3fc5d6a124
5 changed files with 26 additions and 0 deletions

View File

@@ -30,6 +30,7 @@ namespace GHelper
{"aura", Properties.Strings.ToggleAura}, {"aura", Properties.Strings.ToggleAura},
{"performance", Properties.Strings.PerformanceMode}, {"performance", Properties.Strings.PerformanceMode},
{"screen", Properties.Strings.ToggleScreen}, {"screen", Properties.Strings.ToggleScreen},
{"lock", Properties.Strings.LockScreen},
{"miniled", Properties.Strings.ToggleMiniled}, {"miniled", Properties.Strings.ToggleMiniled},
{"fnlock", Properties.Strings.ToggleFnLock}, {"fnlock", Properties.Strings.ToggleFnLock},
{"brightness_down", Properties.Strings.BrightnessDown}, {"brightness_down", Properties.Strings.BrightnessDown},

View File

@@ -473,6 +473,10 @@ namespace GHelper.Input
case "screenshot": case "screenshot":
KeyboardHook.KeyPress(Keys.Snapshot); KeyboardHook.KeyPress(Keys.Snapshot);
break; break;
case "lock":
Logger.WriteLine("Screen lock");
NativeMethods.LockScreen();
break;
case "screen": case "screen":
Logger.WriteLine("Screen off toggle"); Logger.WriteLine("Screen off toggle");
NativeMethods.TurnOffScreen(); NativeMethods.TurnOffScreen();

View File

@@ -32,6 +32,15 @@ public class NativeMethods
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, out string lpBuffer, uint nSize, IntPtr Arguments); private static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, out string lpBuffer, uint nSize, IntPtr Arguments);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool LockWorkStation();
public static void LockScreen()
{
LockWorkStation();
}
public static void TurnOffScreen() public static void TurnOffScreen()
{ {
Form f = new Form(); Form f = new Form();

View File

@@ -1223,6 +1223,15 @@ namespace GHelper.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Lock Screen.
/// </summary>
internal static string LockScreen {
get {
return ResourceManager.GetString("LockScreen", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Logo. /// Looks up a localized string similar to Logo.
/// </summary> /// </summary>

View File

@@ -506,6 +506,9 @@ Do you still want to continue?</value>
<data name="Lighting" xml:space="preserve"> <data name="Lighting" xml:space="preserve">
<value>Lighting</value> <value>Lighting</value>
</data> </data>
<data name="LockScreen" xml:space="preserve">
<value>Lock Screen</value>
</data>
<data name="Logo" xml:space="preserve"> <data name="Logo" xml:space="preserve">
<value>Logo</value> <value>Logo</value>
</data> </data>