Prevent Screen Saver from idle ten minute with power shell script
Clear-Host
Echo "Keep-alive with mouse Jitter..."
Add-Type -AssemblyName System.Windows.Forms
while($true)
{
$mouse_position = [System.Windows.Forms.Cursor]::Position
$x = ($mouse_position.X % 1024) + 1
$y = ($mouse_position.Y % 1024) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x,$y)
Start-Sleep -Seconds 300
}
#@combine mouse jitter and scroll lock
Clear-Host
Echo "Keep-alive with mouse Jitter and scroll lock..."
Add-Type -AssemblyName System.Windows.Forms
$wsshell = New-Object -com "Wscript.Shell"
while($true)
{
$mouse_position = [System.Windows.Forms.Cursor]::Position
$x = ($mouse_position.X % 1024) + 1
$y = ($mouse_position.Y % 1024) + 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x,$y)
Start-Sleep -Seconds 59
$wsshell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Milliseconds 59000
$wsshell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Seconds 590
}
#@keep-alive with F15
Clear-Host
Echo "Keep-alive with F15 key stroke..."
$wsshell = New-Object -com "Wscript.Shell"
while(1)
{
$wsshell.sendkeys("+{F15}")
Start-Sleep -Seconds 590
}
References
https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/
https://gist.github.com/MatthewSteeples/ce7114b4d3488fc49b6a
https://stackoverflow.com/questions/15835941/powershell-mouse-move-does-not-prevent-idle-mode
https://techexpert.tips/powershell/powershell-moving-mouse-automatically/