Created
July 15, 2025 08:30
-
-
Save nopeless/1c312e6d4c65e758368d92a6d2e32632 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Requires AutoHotkey v2.0 | |
| #SingleInstance | |
| #UseHook | |
| ; V2 rewrite and simplification by author: nopeless @ github.com | |
| ; | |
| ; Originally written by Lexikos (404) | |
| ; http://www.autohotkey.com/forum/post-147849.html#147849 | |
| ; Modifications by Trevor Bekolay for the How-To Geek | |
| ; http://www.howtogeek.com/ | |
| #<!l:: { | |
| KeyWait "LWin" | |
| KeyWait "LAlt" | |
| KeyWait "l" | |
| MsgBox("Windows+Alt+L to unlock (Click OK to start blocking)") | |
| BlockKeyboard(true) | |
| } | |
| BlockKeyboard(block) { | |
| Static hHook := 0, cb := "" | |
| If (!cb) | |
| cb := CallbackCreate(BlockKeyboard_HookProc) | |
| If (block && !hHook) { | |
| hHook := DllCall("SetWindowsHookEx" | |
| , "int", 13 | |
| , "ptr", cb | |
| , "ptr", 0 | |
| , "uint", 0) | |
| } | |
| If (!block && hHook) { | |
| DllCall("UnhookWindowsHookEx", "ptr", hHook) | |
| hHook := 0 | |
| } | |
| } | |
| BlockKeyboard_HookProc(nCode, wParam, lParam) | |
| { | |
| Static winPressed := 0, altPressed := 0 | |
| if (NumGet(lParam, 8, "UInt") & 0x80) { | |
| winPressed := 0 | |
| altPressed := 0 | |
| return 1 | |
| } | |
| key := NumGet(lParam, 4, "UInt") | |
| if (key = 91) { | |
| winPressed := 1 | |
| return 1 | |
| } | |
| if (key = 56) { | |
| altPressed := 1 | |
| return 1 | |
| } | |
| if (winPressed && altPressed && key = 38) | |
| { | |
| BlockKeyboard(false) | |
| winPressed := 0 | |
| altPressed := 0 | |
| } | |
| return 1 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Replace
BlockKeyboardwith this to also block mouse inputs