Last active
October 31, 2025 19:04
-
-
Save StudioEtrange/e5e4defdc6942f252a267edfdb05e89c to your computer and use it in GitHub Desktop.
Windows : Stay awake and avoid the saving screen by pressing a fake key : launch this powsershell script
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
| # Useful references: | |
| # | |
| # https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line | |
| # https://ss64.com/vb/sendkeys.html | |
| # https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell | |
| # https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/ | |
| # | |
| # Future enhancements - use events rather than an infinite loop | |
| while (1) { | |
| $wsh = New-Object -ComObject WScript.Shell | |
| # Send Shift+F15 - this is the least intrusive key combination I can think of and is also used as default by: | |
| # http://www.zhornsoftware.co.uk/caffeine/ | |
| # Unfortunately the above triggers a malware alert on Saophos so I needed to find a native solution - hence this script... | |
| $wsh.SendKeys('+{F15}') | |
| Start-Sleep -seconds 59 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment