Script/command to temporarily lock keyboard and mouse

I need either a script or a terminal command that will lock / temporarily suspend input from both the keyboard and mouse for 30 seconds.

The script so far looks like this:

tell the application "Finder" to activate
tell the application "Finder" to display dialog "That action is not allowed on public machines" with icon stop buttons {"Cancel it!"} default button 1
if the button returned of the result is "Cancel it!" then tell the application "ScreenSaverEngine" to activate

The screensaver that activates is “KPSaver” (the kernel panic screen saver).

The script will be run as an application via remote desktop, and it would be nice if there was another separate app that would immediately cancel the first app.

Any help greatly appreciated.

Hi,

you shouldn’t disable mouse or keyboard input,
because you will bite the hand that feeds you.

If mouse and keyboard are connected via bluetooth,
you could disable / enable bluetooth but then you need another script to force pairing both devices.

If mouse and keyboard are connected via USB,
there is no way unless you remove temporarily the USB kext file. I strongly recommend not to do this!