Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltpitt/a4c0503308476c0da52fb3b3a3c7d0ac to your computer and use it in GitHub Desktop.
Save ltpitt/a4c0503308476c0da52fb3b3a3c7d0ac 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 the preferred delay between each keypress
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