Last active
February 24, 2025 02:44
-
-
Save Nightblade/ed67e942386834d3c75362124851e4ea to your computer and use it in GitHub Desktop.
Block keyboard input so you can clean it while it's plugged in.
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 | |
/* | |
KeyboardClean.ahk | |
------------------ | |
Temporarily disables keyboard input to allow cleaning while plugged in. | |
Version History: | |
v2.2 - 2025-02-24 (Re-enable keyboard on exit as a precaution) | |
v2.1 - 2025-02-22 (Merged enable/disable functions into a toggle) | |
v2.0 - 2025-01-14 | |
v1.0 - 2025-01-02 | |
*/ | |
Global AppName := "Keyboard Cleaner" | |
Global AppVersion := "2.2" | |
Global IsKeyboardEnabled := True ; Tracks keyboard state | |
#SingleInstance | |
InstallKeybdHook | |
GuiWindow := Gui("+AlwaysOnTop -MinimizeBox -MaximizeBox -SysMenu -Resize", AppName . " " . AppVersion) | |
ToggleButton := GuiWindow.Add("Button", "y+10", "Disable Keyboard") | |
ToggleButton.OnEvent("Click", ToggleKeyboard) | |
GuiWindow.Add("Button", "x+10", "Quit").OnEvent("Click", QuitApp) | |
GuiWindow.Show() | |
ToggleKeyboard(*) { | |
Global IsKeyboardEnabled := !IsKeyboardEnabled ; Toggle global state | |
Loop 512 { | |
Hotkey Format("SC{:X}", A_Index), IsKeyboardEnabled ? "Off" : BlockKey, "On" | |
} | |
ToggleButton.Text := IsKeyboardEnabled ? "Disable Keyboard" : "Enable Keyboard" | |
} | |
QuitApp(*) { | |
if not IsKeyboardEnabled { | |
ToggleKeyboard | |
} | |
ExitApp | |
} | |
BlockKey(ThisHotkey) { | |
Return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment