How to change a setting of the touchpad via AHK

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
science2002
Posts: 31
Joined: 29 Oct 2016, 05:18

How to change a setting of the touchpad via AHK

Post by science2002 » 16 May 2024, 15:42

I am trying to disable the "drag two fingers to scroll" - a feature of the touchpad - that can be switch on/off using Win Settings. I have an application from a decade ago (it runs perfectly on WinXP) that crashes when the above action is taken in Win10 64bit. I was looking a way to disable that feature when my app (call it MyApp.exe) was active.

By monitoring the registry I found what changes are made in the registry when that feature was switch on/off using Win Settings. However, if the registr is changed manually, or using AHK (see below) it does not work immediately. I need to reboot the machine to make it work, contrary to what happens by using the win settings, which result is instantaneous.

Is there a way to correct the code below, so to make it work, so "to refresh" the registry without "rebooting" the machine? Or more specifically (in my case), is it possible to disable "drag two fingers to scroll" (or any other Win Setting) using AHK?

Code: Select all

SetTitleMatchMode, 2  ; Set title matching to "contains"

#Persistent  ; Keep the script running

Loop {
    WinGetActiveTitle, ActiveTitle
    IfInString, ActiveTitle, MyApp  {
        ; Disable touchpad scrolling by modifying the registry
        RegWrite, REG_DWORD, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad, PanEnabled, 0  ; Set to 0 to disable scrolling
   } Else {
        ; Enable touchpad scrolling by modifying the registry
        RegWrite, REG_DWORD, HKCU, SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad, PanEnabled, 1  ; Set to 1 to enable scrolling
    }
    Sleep, 1000  ; Check every second
Thanks for any help.

Return to “Ask for Help (v1)”