Created
May 15, 2025 09:33
-
-
Save mage1k99/69f357fcdef6f979b3d6f31c4dbfa2b6 to your computer and use it in GitHub Desktop.
Keeps your screen awake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Store the start time | |
$startTime = Get-Date | |
# Create WScript.Shell object | |
$wshell = New-Object -com "Wscript.Shell" | |
# Function to format timespan in a human readable way | |
function Format-TimeSpan { | |
param ( | |
[TimeSpan]$TimeSpan | |
) | |
$days = $TimeSpan.Days | |
$hours = $TimeSpan.Hours | |
$minutes = $TimeSpan.Minutes | |
$seconds = $TimeSpan.Seconds | |
$parts = @() | |
if ($days -gt 0) { $parts += "$days days" } | |
if ($hours -gt 0) { $parts += "$hours hours" } | |
if ($minutes -gt 0) { $parts += "$minutes minutes" } | |
if ($seconds -gt 0) { $parts += "$seconds seconds" } | |
return [string]::Join(", ", $parts) | |
} | |
$motivationalMessages = @( | |
"Warning: AFK mode terminated. Time to get back to work! Remember, 'I am the one who knocks... out tasks!' - Heisenberg", | |
"Your productivity is calling... and it's not a telemarketer. Answer the call and crush your tasks!", | |
"AFK mode: disabled. Productivity mode: enabled. Now, go forth and 'May the code be with you!'", | |
"Procrastination is like the Dementors - it'll suck the happiness out of you. Cast a Patronus of productivity and chase them away!", | |
"Your work is like a pizza - even when it's bad, it's still pretty good. So, get back to work and deliver that pizza!", | |
"You've got this! After all, 'Happiness can be found even in the darkest of times if one only remembers to turn on the light.' - Albus Dumbledore", | |
"Time to swap AFK for IWK (I'm Working, Kthx). Get back to work and show the world what you're made of!", | |
"Productivity is like a video game - you level up, you get rewards, and you feel awesome! So, play on!", | |
"Remember, Walter White didn't become Heisenberg by slacking off. Get back to work and cook up some productivity!" | |
) | |
Write-Host "Starting CapsLock toggle at: $startTime" | |
Write-Host "Press Ctrl+C to stop..." | |
try { | |
While ($true) { | |
$WShell.sendkeys("{CAPSLOCK}") | |
Write-Host "BEEP" -ForegroundColor Cyan | |
Start-Sleep -Milliseconds 100 | |
$Wshell.sendkeys("{CAPSLOCK}") | |
Write-Host "BOOP" -ForegroundColor Green | |
Start-Sleep -Seconds 200 | |
} | |
} finally { | |
$endTime = Get-Date | |
$duration = $endTime - $startTime | |
$randomMessage = Get-Random -InputObject $motivationalMessages | |
Write-Host "`n----------------------------------------" | |
Write-Host "Script Statistics:" | |
Write-Host "Start time: $startTime" | |
Write-Host "End time: $endTime" | |
Write-Host "Total runtime: $(Format-TimeSpan -TimeSpan $duration)" | |
Write-Host "`n$randomMessage" -ForegroundColor Yellow | |
Write-Host "----------------------------------------" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment