Skip to content

Instantly share code, notes, and snippets.

@schwartzmx
Created January 13, 2017 06:07
Show Gist options
  • Save schwartzmx/87f41a822095d8677f05b1c6b40b564b to your computer and use it in GitHub Desktop.
Save schwartzmx/87f41a822095d8677f05b1c6b40b564b to your computer and use it in GitHub Desktop.
Block user input. Mouse, and keyboard are disabled for the duration.
$code = @"
[DllImport("user32.dll")]
public static extern bool BlockInput(bool fBlockIt);
"@
$userInput = Add-Type -MemberDefinition $code -Name UserInput -Namespace UserInput -PassThru
Function Disable-UserInput {
param([int]$Seconds=5)
$userInput::BlockInput($true) | out-null
Start-Sleep $seconds
$userInput::BlockInput($false) | out-null
}
Disable-UserInput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment