mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Touchscreen toggle binding https://github.com/seerge/g-helper/issues/2575
This commit is contained in:
@@ -36,6 +36,7 @@ namespace GHelper
|
||||
{"brightness_down", Properties.Strings.BrightnessDown},
|
||||
{"brightness_up", Properties.Strings.BrightnessUp},
|
||||
{"visual", Properties.Strings.VisualMode},
|
||||
{"touchscreen", Properties.Strings.ToggleTouchscreen },
|
||||
{"ghelper", Properties.Strings.OpenGHelper},
|
||||
{"custom", Properties.Strings.Custom}
|
||||
};
|
||||
|
||||
23
app/Helpers/TouchscreenHelper.cs
Normal file
23
app/Helpers/TouchscreenHelper.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using GHelper.Helpers;
|
||||
|
||||
public static class TouchscreenHelper
|
||||
{
|
||||
public static bool? ToggleTouchscreen()
|
||||
{
|
||||
try
|
||||
{
|
||||
ProcessHelper.RunAsAdmin();
|
||||
|
||||
var status = !ProcessHelper.RunCMD("powershell", "(Get-PnpDevice -FriendlyName '*touch*screen*').Status").Contains("OK");
|
||||
ProcessHelper.RunCMD("powershell", (status ? "Enable-PnpDevice" : "Disable-PnpDevice") + " -InstanceId (Get-PnpDevice -FriendlyName '*touch*screen*').InstanceId -Confirm:$false");
|
||||
|
||||
return status;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WriteLine($"Can't toggle touchscreen: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -544,6 +544,11 @@ namespace GHelper.Input
|
||||
case "controller":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
|
||||
break;
|
||||
case "touchscreen":
|
||||
var touchscreenStatus = TouchscreenHelper.ToggleTouchscreen();
|
||||
if (touchscreenStatus is not null)
|
||||
Program.toast.RunToast(Properties.Strings.Touchscreen + " " + ((bool)touchscreenStatus ? Properties.Strings.On : Properties.Strings.Off), ToastIcon.Touchpad);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
18
app/Properties/Strings.Designer.cs
generated
18
app/Properties/Strings.Designer.cs
generated
@@ -1925,6 +1925,24 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Toggle Touchscreen.
|
||||
/// </summary>
|
||||
internal static string ToggleTouchscreen {
|
||||
get {
|
||||
return ResourceManager.GetString("ToggleTouchscreen", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to .
|
||||
/// </summary>
|
||||
internal static string Touchscreen {
|
||||
get {
|
||||
return ResourceManager.GetString("Touchscreen", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Turbo.
|
||||
/// </summary>
|
||||
|
||||
@@ -740,6 +740,12 @@ Do you still want to continue?</value>
|
||||
<data name="ToggleScreen" xml:space="preserve">
|
||||
<value>Toggle Screen</value>
|
||||
</data>
|
||||
<data name="ToggleTouchscreen" xml:space="preserve">
|
||||
<value>Toggle Touchscreen</value>
|
||||
</data>
|
||||
<data name="Touchscreen" xml:space="preserve">
|
||||
<value />
|
||||
</data>
|
||||
<data name="Turbo" xml:space="preserve">
|
||||
<value>Turbo</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user