PowerShell: Prevent screen saver, lock: Move mouse regularly
Alternatively, if you can't change the screen lock settings, you can move the mouse regularly, or have a script move the mouse. Originally published as an AutoIt script, I recreated the script with a few PowerShell lines. Anyone who copies the following commands into a PowerShell session will prevent the computer from locking the screen or starting the screensaver:
Add-Type -AssemblyName System.Windows.Forms
while ($true)
{
$Pos = [System.Windows.Forms.Cursor]::Position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(($pos.X+1), ($pos.Y+1))
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($pos.X, $pos.Y)
Start-Sleep -Seconds 60
}
To run: Copy content to clipboard and:
The script moves the mouse one pixel and back every 60 seconds.

{{percentage}} % positive

THANK YOU for your review!
created by Bernhard
| published: 2022-12-02
| Updated: 2022-12-02 |
Übersetzung Deutsch
|🔔
| Comments:0