Skip to content

Instantly share code, notes, and snippets.

@MatthewSteeples
Created February 26, 2015 19:09
Show Gist options
  • Save MatthewSteeples/ce7114b4d3488fc49b6a to your computer and use it in GitHub Desktop.
Save MatthewSteeples/ce7114b4d3488fc49b6a to your computer and use it in GitHub Desktop.
Powershell Script to keep the mouse moving
Add-Type -AssemblyName System.Windows.Forms
while ($true)
{
$Pos = [System.Windows.Forms.Cursor]::Position
$x = ($pos.X % 500) + 1
$y = ($pos.Y % 500) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
Start-Sleep -Seconds 10
}
@quonic
Copy link

quonic commented Sep 21, 2023

Thanks for the reply. In my case, when i run the script (right click and run with powershell) the window opens for a split second and then disappears, and it doesn't even show up in the task manager.

Reboot. Then just use my code. When you press Caps Lock it will quit the script.

@IndieKid28
Copy link

IndieKid28 commented Sep 21, 2023

Thanks for the reply. In my case, when i run the script (right click and run with powershell) the window opens for a split second and then disappears, and it doesn't even show up in the task manager.

Reboot. Then just use my code. When you press Caps Lock it will quit the script.

Will this be detected by any monitoring app? Like powershell running or windows desktop runtime etc. ? Also your script doesn't seem to work for me. The screen keeps turning off regardless.

EDIT: strangely enough, the starting piece of code which was working earlier doesn't work anymore either.

@IndieKid28
Copy link

Use my script instead.

Are you sure the script is really what's holding up your shutdown? I do not believe it would.

Furthermore, are you sure the script is really running? Try opening PS as admin and running Set-ExecutionPolicy -ExecutionPolicy RemoteSigned CurrentUser (or LocalMachine). If that runs successfully, close PS and try again.

Will this be detected by any monitoring app? Like powershell running or windows desktop runtime etc. ? Also your script doesn't seem to work for me. The screen keeps turning off regardless.

The purpose of this script is not so you can sit AFK your entire day at work and pretend otherwise. It's so that when you go to the bathroom or whatever your VPN session doesn't lock on you, or when you talk to someone near your computer it doesn't lock on you. If your IT or whomever department "catches" you doing THAT, tell them to go to Hell.

Is this implementation mimicking mouse movement or is it just sending keystrokes? Because the sending keystrokes scripts don't seem to make me not show up as afk. I would need a mouse mover script.

@IndieKid28
Copy link

@AndrewDavis Who asked? Also judging by how you called someone a "retard" for suggesting something, I'm sure you're the last person to be taking life advices from lmao. Grow up clown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment