Skip to content

Instantly share code, notes, and snippets.

@ryancole
Last active August 31, 2019 02:14
Show Gist options
  • Save ryancole/04491a497e2590fa521821f67dd82b5c to your computer and use it in GitHub Desktop.
Save ryancole/04491a497e2590fa521821f67dd82b5c to your computer and use it in GitHub Desktop.
# https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
while (1) {
$duration = Get-Random -Minimum 10 -Maximum 60
Write-Output "Waiting $duration seconds ...";
Start-Sleep -Seconds $duration
$inputs = ('w', 'a', 's', 'd', ' ');
$input = $inputs[(Get-Random -Maximum $inputs.Length) - 1]
Write-Output "Sending $input ...";
[System.Windows.Forms.SendKeys]::SendWait($input);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment