SPI_SETGESTURE = 0x09B maybe already not right on Win11 24H2, I use frida to detect the value is SPI_SETGESTURE = 0x2031
How to Enable/Disable Three- and four-finger touch gestures using C#?
Hi Everyone, Just want to ask if is there any C# code to enable/disable the Three- and four-finger touch gestures in Windows. Settings > Bluetooth & devices > Touch > Three- and four-finger touch gestures I have some options related to registry modification: [HKEY_CURRENT_USER\Control Panel\Desktop]
three-and four-finger touch gestures to on:
"TouchGestureSetting"=dword:00000001
Three four-finger touch gestures to off:
"TouchGestureSetting"=dword:00000000
But after modification of this need to restart the machine. I expect to enable or disable this option without restarting the machine.
Thanks & Regards Amit Kumar
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
2 answers
Sort by: Most helpful
-
-
Anonymous
2024-02-13T07:07:38.7766667+00:00 Hi @Kumar, Amit - Dell Team , Welcome to Microsoft Q&A,
If you want to use C# to modify the registry, you can try to useRegistry.GetValue(String, String, Object) Method.
To modify the registry using C# and enable/disable the three- and four-finger touch gestures without requiring a machine restart, you can use the Microsoft.Win32 namespace. A similar example code is:
using System; using Microsoft.Win32; using System.Runtime.InteropServices; class Program { // Define the constants for SPI_SETGESTURE (touch gestures) private const uint SPI_SETGESTURE = 0x009B; private const uint SPIF_SENDCHANGE = 0x02; // Define the flags for touch gestures private const uint GESTURE_ENABLE = 1; private const uint GESTURE_DISABLE = 0; // Import the SystemParametersInfo function from user32.dll [DllImport("user32.dll", SetLastError = true)] private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni); static void Main(string[] args) { // Modify the registry to enable/disable touch gestures ModifyTouchGestureSettings(GESTURE_ENABLE); // Change this to GESTURE_DISABLE if you want to disable // Notify the system about the change SystemParametersInfo(SPI_SETGESTURE, 0, IntPtr.Zero, SPIF_SENDCHANGE); Console.WriteLine("Touch gesture settings updated."); } // Function to modify the registry settings static void ModifyTouchGestureSettings(uint setting) { // Registry key path const string keyPath = @"HKEY_CURRENT_USER\Control Panel\Desktop"; // Registry value name const string valueName = "TouchGestureSetting"; // Modify the registry value Registry.SetValue(keyPath, valueName, setting, RegistryValueKind.DWord); } }Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.