For the keyboard, there is this application. It was originally as an AutoHotKey script turned into an executable. Conveniently, they also include the AutoHotKey script in the .zip, so you can either run the script yourself, or just run the executable. I've tested it (the executable), and it seems to work fine. Simply type Ctrl + Alt + L and it will disable nearly everything except a few key combinations as mentioned on that site. To unlock your keyboard, type "unlock".
The script is:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; THE KEYBOARD LOCKER ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; This script will disable the keyboard when the user ;
; presses Ctrl+Alt+L. The keyboard is reenabled if the user ;
; types in the string "unlock". ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Originally written by Lexikos: ;
; http://www.autohotkey.com/forum/post-147849.html#147849 ;
; Modifications by Trevor Bekolay for the How-To Geek ;
; http://www.howtogeek.com/ ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#Persistent
FileInstall, enabled.ico, enabled.ico, 0
FileInstall, disabled.ico, disabled.ico, 0
Init()
ToggleTray:
ToggleTray()
return
Exit:
ExitApp
return
; This can only execute if the keyboard is NOT blocked,
; so it can't be used to unblock the keyboard.
^!l::
KeyWait, Ctrl ; don't block Ctrl key-up
KeyWait, Alt ; or Alt key-up
KeyWait, l ; or l-up
BlockKeyboard()
return
Init()
{
global notray = 0
Menu, Tray, Icon, enabled.ico
Menu, Tray, NoStandard
Menu, Tray, Tip, Press Ctrl+Alt+L to lock your keyboard
Menu, Tray, Add, Hide tray notifications, ToggleTray
Menu, Tray, Add, Exit, Exit
TrayTip,,To lock your keyboard press Ctrl+Alt+L.,10,1
}
ToggleTray()
{
global notray
if (notray = 0) {
notray = 1
Menu, Tray, Rename, Hide tray notifications, Show tray notifications
} else {
notray = 0
Menu, Tray, Rename, Show tray notifications, Hide tray notifications
}
}
BlockKeyboard(block=-1) ; -1, true or false.
{
static hHook = 0, cb = 0
global notray
if !cb ; register callback once only.
cb := RegisterCallback("BlockKeyboard_HookProc")
if (block = -1) ; toggle
block := (hHook=0)
if ((hHook!=0) = (block!=0)) ; already (un)blocked, no action necessary.
return
if (block) {
if (notray = 0) {
; Show TrayTip to remind user of unlock string
TrayTip,
,Your keyboard is now locked.`nType in "unlock" to unlock it.
,10,1
}
Menu, Tray, Icon, disabled.ico ; Change tray icon
Menu, Tray, Tip, Type "unlock" to unlock your keyboard
hHook := DllCall("SetWindowsHookEx"
, "int", 13 ; WH_KEYBOARD_LL
, "uint", cb ; lpfn (callback)
, "uint", 0 ; hMod (NULL)
, "uint", 0) ; dwThreadId (all threads)
}
else {
if (notray = 0) {
TrayTip,
,Your keyboard is now unlocked.`nPress Ctrl+Alt+L to lock it again.
,10,1
}
Menu, Tray, Icon, enabled.ico ; Change tray icon
Menu, Tray, Tip, Press Ctrl+Alt+L to lock your keyboard
DllCall("UnhookWindowsHookEx", "uint", hHook)
hHook = 0
}
}
BlockKeyboard_HookProc(nCode, wParam, lParam)
{
static count = 0
; Unlock keyboard if "unlock" typed in
if (NumGet(lParam+8) & 0x80) { ; key up
if (count = 0 && NumGet(lParam+4) = 0x16) { ; 'u'
count = 1
} else if (count = 1 && NumGet(lParam+4) = 0x31) { ; 'n'
count = 2
} else if (count = 2 && NumGet(lParam+4) = 0x26) { ; 'l'
count = 3
} else if (count = 3 && NumGet(lParam+4) = 0x18) { ; 'o'
count = 4
} else if (count = 4 && NumGet(lParam+4) = 0x2E) { ; 'c'
count = 5
} else if (count = 5 && NumGet(lParam+4) = 0x25) { ; 'k'
count = 0
BlockKeyboard(false)
} else {
count = 0
}
}
return 1
}
For the mouse, I also found this AutoHotKey (version 2) script. Press F to disable your mouse (clicks, movement, and wheel), and Ctrl + C to enable it again. You can modify the script to change those keys as you wish obviously.
; This script blocks mouse movement, mouse buttons, and wheel
#Requires AutoHotkey v2.0
BlockTheMouse := False
f:: {
Global BlockTheMouse := True
BlockInput 'MouseMove'
SoundBeep 1500
}
^c:: {
Global BlockTheMouse:= False
BlockInput 'MouseMoveOff'
SoundBeep 1000
}
#HotIf BlockTheMouse
LButton::
RButton::
MButton::
XButton1::
XButton2::
WheelUp::
WheelDown::
WheelLeft::
WheelRight::Return
#HotIf
The only issue here is, the first script is AutoHotKey version 1, while the second script is version 2. So you'll need both versions of AutoHotKey installed, which I believe is fine, but a bit annoying. I would probably run the .exe for the keyboard locker, and the script to disable the mouse so I wouldn't have to have an outdated version of AutoHotKey installed.