Skip to content

Keep Windows Screen Awake

This is a Windows PowerShell script to keep a windows screen awake. It simulates a F15 key press every 1 minute to 5 minutes (randomnly).

How to Run

powershell -ExecutionPolicy Bypass -F .\screen-keep-awake.ps1

Script

screen-keep-awake.ps1
$wsh = New-Object -ComObject WScript.Shell

while (1) {
    "Sending key F15..."
    $wsh.SendKeys('+{F15}')
    $RNDSleep = Get-Random -Minimum 60 -Maximum 300 
    $MINS = $RNDSLeep/60
    Write-Host "Sleeping "$MINS" minutes... )"
    Start-Sleep -Seconds $RNDSleep
}