Lock your keyboard and/or mouse while you clean them. Hold F12 for 5 seconds to unlock everything.
- Install AutoHotkey v2.
- Save
CleanLock.ahkas UTF-8 (no BOM is fine, ANSI is not). - Double-click it. The window appears.
- Pick Lock KEYBOARD, Lock MOUSE, or Lock BOTH.
- Wait out the 3-second pre-delay. Click Cancel Pending to abort.
- Clean.
- Hold F12 for 5 seconds. A blue bar fills under the status text.
- If you forget, the watchdog unlocks everything on its own (default 120s).
| Symptom in v1 ↕▾ | Cause ↕▾ | Fix in v2 ↕▾ |
|---|---|---|
−^!m did not unlock the mouse |
The M key is inside the *vkXX block list. If the keyboard was also locked, ^!m could never fire |
Removed. One universal escape: hold F12 |
| Triple right-click unlock did nothing | Right-click was blocked by the same list, so ~RButton never got clean presses |
Removed |
Ctrl+Alt+Del did not unlock |
Windows reserves it. No AHK script can block or hook it | Documented as impossible. Watchdog is the real fallback |
| Script crashed on start | Arrow functions assigned globals and silently created locals, so the watchdog timer never armed | All globals declared explicitly in every function |
| ⚙ |
- Ctrl+Alt+Del and Win+L cannot be blocked. Windows handles them in secure mode.
- The physical power button is unaffected.
- Devices with their own drivers (some gaming mice and touchpads) may pass input through AHK's hook.
- Elevated windows (Task Manager, UAC) do not receive blocked input from a non-elevated script. Run as admin if that matters.
Top of CleanLock.ahk:
HOLD_KEY := "F12" ; any key name: "Pause", "CapsLock", "F9"
HOLD_SECS := 5
PRE_SECS := 3
DEFAULT_WD := 120
If you change HOLD_KEY, the block list automatically skips its VK, so the
hold key keeps working.
Anyone can press Ctrl+Alt+Del, open Task Manager, and end the script. This is a cleaning convenience tool, not access control.
MIT