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_down", Properties.Strings.BrightnessDown},
|
||||||
{"brightness_up", Properties.Strings.BrightnessUp},
|
{"brightness_up", Properties.Strings.BrightnessUp},
|
||||||
{"visual", Properties.Strings.VisualMode},
|
{"visual", Properties.Strings.VisualMode},
|
||||||
|
{"touchscreen", Properties.Strings.ToggleTouchscreen },
|
||||||
{"ghelper", Properties.Strings.OpenGHelper},
|
{"ghelper", Properties.Strings.OpenGHelper},
|
||||||
{"custom", Properties.Strings.Custom}
|
{"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":
|
case "controller":
|
||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
|
Program.settingsForm.BeginInvoke(Program.settingsForm.allyControl.ToggleModeHotkey);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Turbo.
|
/// Looks up a localized string similar to Turbo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -740,6 +740,12 @@ Do you still want to continue?</value>
|
|||||||
<data name="ToggleScreen" xml:space="preserve">
|
<data name="ToggleScreen" xml:space="preserve">
|
||||||
<value>Toggle Screen</value>
|
<value>Toggle Screen</value>
|
||||||
</data>
|
</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">
|
<data name="Turbo" xml:space="preserve">
|
||||||
<value>Turbo</value>
|
<value>Turbo</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Reference in New Issue
Block a user