block all device input ecxept one (powershell)

Viewed 24

My problem is that the Arduino program i wrote opens muiltiply windows and i need to lock all user's inputs except arduino one, for user to not ruin it. and i need to do it in powershell.

I found scripts like this:

$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 10 | Out-Null

and tried use pnpdevices command:

Get-PnpDevice -FriendlyName "*keyboard*", "*mouse*" | Disable-PnpDevice -Force
Get-PnpDevice | Where-Object {$_.Problem -eq 22} | Enable-PnpDevice

But it steal not what i need, i need uninterrupted connection with arduino. Hope to hear your suggestions!

0 Answers
Related