SEARCH

How-To Geek

TouchFreeze Alternative in AutoHotkey

A few months back, LH posted a link to TouchFreeze: http://lifehacker.com/5412986/touchfreeze-disables-your-touchpad-as-soon-as-you-start-typing

This program was designed to stop you from accidentally hitting your laptop/netbook’s trackpad with your thumbs while you are typing. However, this program didn’t really work for me – I still accidentally jumped the cursor from time-to-time.

So here’s my Autohotkey version, which has been working very well for me for the last couple of weeks since I created it. (Note that you can tweak the timer line if the 500ms default still isn’t quite long enough for you.) I’ve noticed no performance lag at all with method, since it’s a keyboard hook.

I think it’s always better to add little functions like these to my AHK master script, rather than installing YAU (yet another utility) for these small tweaks.


; Script Function:
; Disables trackpad for 500ms any time a key is pressed (prevents accidental mouse clicks)
;

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

;keyboard hook code credit: http://www.autohotkey.com/forum/post-127490.html#127490
#Persistent
OnExit, Unhook

hHookKeybd := SetWindowsHookEx(WH_KEYBOARD_LL := 13, RegisterCallback("Keyboard", "Fast"))
Return

ReenableTrackpad:
BlockInput, MouseMoveOff
Return

Unhook:
UnhookWindowsHookEx(hHookKeybd)
ExitApp

Keyboard(nCode, wParam, lParam)
{
Critical
If !nCode
{
BlockInput, MouseMove
SetTimer, ReenableTrackpad, 500
}
Return CallNextHookEx(nCode, wParam, lParam)
}

SetWindowsHookEx(idHook, pfn)
{
Return DllCall("SetWindowsHookEx", "int", idHook, "Uint", pfn, "Uint", DllCall("GetModuleHandle", "Uint", 0), "Uint", 0)
}

UnhookWindowsHookEx(hHook)
{
Return DllCall("UnhookWindowsHookEx", "Uint", hHook)
}

CallNextHookEx(nCode, wParam, lParam, hHook = 0)
{
Return DllCall("CallNextHookEx", "Uint", hHook, "int", nCode, "Uint", wParam, "Uint", lParam)
}

  • Published 02/22/10

Comments (2)

  1. dblanchard

    Doesn’t appear to work properly for me. I use AHK a great deal, and know that I have it running properly. I’ve also disabled my resident script.

    I’m running Windows 7 on a MacBook Air, and while I love the large touchpad most of the time, I do end up clicking with it while I am typing. The script does prevent me from moving my mouse, but not from clicking it.

    As I type a string of characters, I’m not able to move the mouse, but clicking still works when it shouldn’t. This is a great script idea, and I hope it will be improved.

    D

  2. Jason Faulkner

    Awesome! It seems to very well in Windows 7 Pro.

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!