Mouse Jiggler Script

Simple-help keeps the screen alive and prevents the system from going to sleep natively.
But, it seems this is only the case when keyboard and mouse control is enabled for the tech.
I usually disable my control of the mouse and keyboard during long processes so the user can continue to work as needed, and so I don’t accidently click something. Problem is, if the user is away the screen locks then I am stuck waiting for them to come back and unlock it.

Reddit to the rescue. https://www.reddit.com/r/PowerShell/comments/rxfgzc/one_line_mouse_jiggler/

I am currently giving this script a try and it seems to work.

[int]$movepx = 20
[int]$sleep = 20
Add-Type -AssemblyName System.Windows.Forms
while (1) {
    $prevpos=[System.Windows.Forms.Cursor]::Position
    start-sleep -Seconds $sleep
    $currpos = [System.Windows.Forms.Cursor]::Position
    if ($currpos -eq $prevpos) {
        foreach ($xpos in $(($currpos.X + $movepx), ($currpos.X - $movepx), ($currpos.X))){
            [System.Windows.Forms.Cursor]::Position=New-Object System.Drawing.Point($xpos, $currpos.Y)
        }
    }
}

On Further testing, windows don’t care. The lock screen still triggers when the techs mouse and keyboard is disabled.

Anybody have any ideas?

Have you already thought about changing the lockscreen timeout by editing the registry key? This should work fine.
With the next reboot you can enforce the default setting with a group policy.
As far as I remember its configured by default already.

I thought about that.
I don’t want to mess with clients’ group policies if they have them.

Looking for something that I can just turn on and off real quick as needed.