Last active
January 15, 2025 15:11
-
-
Save atao/12b5857d388068bab134d5f9c36241b1 to your computer and use it in GitHub Desktop.
⌨️ Lock keyboard and mouse during n seconds.
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
#Run As Administrator | |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit } | |
$code = @" | |
[DllImport("user32.dll")] | |
public static extern bool BlockInput(bool fBlockIt); | |
"@ | |
$userInput = Add-Type -MemberDefinition $code -Name UserInput -Namespace UserInput -PassThru | |
function Disable-UserInput($seconds) { | |
$userInput::BlockInput($true) | |
Start-Sleep $seconds | |
$userInput::BlockInput($false) | |
} | |
Disable-UserInput -seconds 4 | Out-Null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment