PowerShell mouse jiggler

Recently, I noticed that our security department had blocked my favorite mouse jiggler, even though it’s open source. I did some Google-ing and was able to throw this together. The script is over at GitHub, but also pasted below (check GitHub first).

# 2018-03-27
# Logan Marchione
# PowerShell script to act as a "mouse jiggler"

# Usage:
#  To run
#    .\mouse_jiggler.ps1
#  To quit
#    Ctrl+C

# How many seconds between jiggles
$seconds=300

# Pixels to jiggle
$pixels=1

# Add the .NET class
Add-Type -AssemblyName System.Windows.Forms

# Loop forever
while ($true) {
  # Get the current mouse position
  $Pos = [System.Windows.Forms.Cursor]::Position
  # Move the mouse a distance to the right, then wait
  [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) + $pixels) , $Pos.Y)
  Start-Sleep -Seconds $seconds

  # Get the current mouse position
  $Pos = [System.Windows.Forms.Cursor]::Position
  # Move the mouse a distance to the left, then wait
  [System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) - $pixels) , $Pos.Y)
  Start-Sleep -Seconds $seconds
}

 

Hope it helps someone!

-Logan

2 thoughts on “PowerShell mouse jiggler

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.