Skip to content

Instantly share code, notes, and snippets.

@neo7BF
Created February 25, 2021 15:46
Show Gist options
  • Save neo7BF/deda3afb61bcc033ce0893fbc3335b55 to your computer and use it in GitHub Desktop.
Save neo7BF/deda3afb61bcc033ce0893fbc3335b55 to your computer and use it in GitHub Desktop.
Devices input management from powershell
####################
# KEYBOARD VERSION #
####################
$shell = New-Object -ComObject WScript.Shell
while(1) {
$shell.sendkeys("{NUMLOCK}{NUMLOCK}")
$time = Get-Date;
$shorterTimeString = $time.ToString("HH:mm:ss");
Write-Host $shorterTimeString "NUMLOCK pressed twice"
#Set your duration between each mouse move
Start-Sleep -Seconds 10
}
#################
# MOUSE VERSION #
#################
#Add-Type -AssemblyName System.Windows.Forms
#$position = [System.Windows.Forms.Cursor]::Position
#$position.X++
#[System.Windows.Forms.Cursor]::Position = $position
#while(1) {
# $position = [System.Windows.Forms.Cursor]::Position
# $position.X++
# [System.Windows.Forms.Cursor]::Position = $position
# $time = Get-Date;
# $shorterTimeString = $time.ToString("HH:mm:ss");
# Write-Host $shorterTimeString "Mouse pointer has been moved 1 pixel to the right"
#Set your duration between each mouse move
# Start-Sleep -Seconds 10
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment