Page 1 of 1

Prevent accidental clicks of thinkpad x230 touchpad

Posted: 28 Mar 2024, 13:09
by TOTAL
Touchpad has never worked 100% reliably on thinkpads, but the greatest nuisance has always been the proneness to accidental touching while typing. There were some driver versions which tried to address that but never reliably.

So I have some up with an idea - and gemini put it to action: the touchpad and its left click should only work when fn button is pressed. Makes you use the mouse as a minigun, so no drinking coffee while navigating the screen but it has become completely immune to accidental touches.

Still not perfect, but does the trick.

Code: Select all


#NoEnv
SendMode Input

; State variable to keep track of whether Fn key is pressed
FnKeyPressed := 0

; Check if the Fn key (SC163) is being pressed
SC163::
    FnKeyPressed := 1
    BlockInput, MouseMoveOff ; Enable mouse input
    SetTimer, DisableMouseInput, -1 ; Set a timer to disable mouse input after 1 ms
return

; Check if the Fn key (SC163) is being released
SC163 Up::
    FnKeyPressed := 0
    BlockInput, MouseMove ; Disable mouse input immediately
return

; Check if the left mouse button is pressed down
LButton::
    if FnKeyPressed = 1
        Send, {LButton Down}
return

; Check if the left mouse button is released
LButton Up::
    Send, {LButton Up}
return

DisableMouseInput:
    If !FnKeyPressed
        BlockInput, MouseMove ; Disable mouse input
return

Re: Prevent accidental clicks of thinkpad x230 touchpad

Posted: 28 Mar 2024, 13:18
by gregster
Hi @TOTAL, I moved your topic from Scripts and Functions (v2) to the corresponding AHK v1 subforum. Perhaps you have missed that AHK v2 is the new main release, and that we have now separate forums for AHK v1 and AHK v2 topics.
(I also fixed a broken code tag - a ] was missing.)

Re: Prevent accidental clicks of thinkpad x230 touchpad

Posted: 28 Mar 2024, 14:05
by TOTAL
OK, thanks. Looks like I must have a dated version installed.

Re: Prevent accidental clicks of thinkpad x230 touchpad

Posted: 28 Mar 2024, 14:27
by gregster
Yes, in a sense - AHK v1 has reached its (official) end of life a few days ago, lexikos won't develop it any further (anyone is free to fork it though, and we continue to provide subforums for it). But please note that v2 has many syntax changes and is not very compatible to most v1 code. But you can have both versions installed at the same time - but this a bit offtopic here.