mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
24 lines
712 B
C#
24 lines
712 B
C#
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;
|
|
}
|
|
|
|
}
|
|
}
|