"drag two fingers to scroll" issue. How to disabale/enable using bat, reg, or ps script

Anthony Queen 0 Reputation points
2024-05-18T07:22:01.1633333+00:00

I am running Win10 Pro 64bit on a Lenovo Thinkpad. I have a program that crashes as soon as I use the 2-finger scrolling in the touchpad (the main window bounches up and down very quickly, then the program stops responding, and crushes). Instead the Lenovo pointer works, including the scrolling feature by dragging and pressing the middle button. I know that there is an option from Win Settings to disable "drag two fingers to scroll". It seems a setting using a UWP: a deprecated software, in my humble opinion, because it is never transparent in what it does. However, monitoring the enable/disable option, I took notice to the following change in the registry:

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad] "PanEnabled"=dword:ffffffff with disable turning into: [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad] "PanEnabled"=dword:00000000

Since I would like to automate the operation using a .bat, or .reg, or .ps script instead to go around the several clicks of the Win Settings, I am asking some help on how to write that script. Or similar alternatives that can automate the enable/disable operation.

Both .bat and .reg files I wrote, were able to change the above registry entry. Yet the feature does not work immediately as it is the case with Win Settings. It needs a reboot. The standard "reload explorer.exe" does not work here. Obviously "reboot" does not make the operation quicker: quite the contrary. So I am here for help.

Thanks.

A.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,866 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anthony Queen 0 Reputation points
    2024-05-19T12:21:21.07+00:00

    Just to add some my attempts to "update the registry" after making the change.

    Here it is a ps (power shell) script that I tried. It does the change I need in the registry (but that's the easy part), yet it fails in updating immediately the new status to the whole system. I hope someone can help.

    # Change the registry key
    Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad" -Name "PanEnabled" -Value 0
    
    # Define the SendNotifyMessageW function
    Add-Type -TypeDefinition @"
    using System;
    using System.Runtime.InteropServices;
    
    public class Settings {
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern bool SendNotifyMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
    
        public static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
        public const int WM_SETTINGCHANGE = 0x1A;
    }
    "@
    
    # Send the WM_SETTINGCHANGE message to all top-level windows with the "PrecisionTouchPad" parameter
    $changeString = [System.Runtime.InteropServices.Marshal]::StringToHGlobalUni("PrecisionTouchPad")
    [Settings]::SendNotifyMessage([Settings]::HWND_BROADCAST, [Settings]::WM_SETTINGCHANGE, [IntPtr]::Zero, $changeString)
    
    # Clean up the allocated string memory
    [System.Runtime.InteropServices.Marshal]::FreeHGlobal($changeString)
    
    
    0 comments No comments