mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added option to lock screen https://github.com/seerge/g-helper/issues/2352
This commit is contained in:
@@ -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},
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
9
app/Properties/Strings.Designer.cs
generated
9
app/Properties/Strings.Designer.cs
generated
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user