Created
May 13, 2019 08:13
-
-
Save xcloudx01/b3557fa23f7ad984ff7fe981245a061a to your computer and use it in GitHub Desktop.
AutoHotKey - Disable keyboard via a hotkey
This file contains 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
RunAsAdmin() | |
RWin & o:: | |
BlockInput On | |
Msgbox,,Anti-Cat Typer,Keyboard & mouse disabled.`nUse Win+P to re-enable. | |
;settimer, remove, 10000 ; as a safety feature while testing | |
return | |
RWin & p:: | |
LWin & p:: | |
blockinput off | |
sendinput,{enter} | |
return | |
;remove: | |
;blockinput off | |
RunAsAdmin() { | |
Loop, %0% ; For each parameter: | |
{ | |
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index. | |
params .= A_Space . param | |
} | |
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA" | |
if not A_IsAdmin | |
{ | |
If A_IsCompiled | |
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1) | |
Else | |
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1) | |
ExitApp | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment