Skip to content

Instantly share code, notes, and snippets.

@bradmartin333
Created August 8, 2022 19:57
Show Gist options
  • Save bradmartin333/37bfd2ecf45ab40da9046032360280fc to your computer and use it in GitHub Desktop.
Save bradmartin333/37bfd2ecf45ab40da9046032360280fc to your computer and use it in GitHub Desktop.
Needlessly complicated way to keep screen awake
$count = [Enum]::GetValues([System.ConsoleColor]).Count
$WShell = New-Object -Com "Wscript.Shell"
$idx = 1
while (1)
{
$WShell.SendKeys("a")
Write-Host ([string]::Format(“No sleeping! {0}”,$idx)) -f ([System.ConsoleColor](Get-Random -Minimum 1 -Maximum $count)).value__
$idx++
sleep 60
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment