Note
This won't work using the "Virtual Desktop". It must be an App (Steam, Playnite, a game, etc)
Freeze your game and put the host to sleep when you disconnect. Resume un-freezes the game.
On disconnect, the game is still running, consuming upward of 200w. The original script freezes the game in focus, bringing idle wattage to 50w~. While this is better, it's still running and doesn't let the computer sleep.
I want console-grade behavior: when I disconnect, the game freezes and the host drops to ~3W sleep; when I reconnect (Wake-on-LAN), the game resumes. Similar to streaming on a PS5 or XBOX.
Force the power action: use SetSuspendState instead of waiting for Windows to idle out. That bypasses the Steam Streaming Speakers power request that otherwise blocks idle sleep. The action is configurable via PowerAction at the top of pause.ahk, POWER_SLEEP (S3, the default) or POWER_HIBERNATE (S4). See "Sleep vs hibernate" below.
On disconnect: freeze the game, then put the host to sleep (S3 by default; set PowerAction := POWER_HIBERNATE for S4).
On reconnect (WoL): un-freeze the game.
On quit: stay awake by default, or sleep too if you set SleepOnQuit := true.
Switching devices: set SleepDelaySec to hold the host awake for a while after a disconnect, so you can pick up on another device before it sleeps.
Keep a shortcut to resume.ahk on your desktop to recover a frozen game by hand.
- AutoHotkey v2.0 installed on the host PC
Same as the original: auto-pause-resume-games
Extract the scripts wherever you like and wire them in Apollo under configuration:
- Command Preparations, Do: {empty} Undo:
resume.ahk - State Commands, Do:
resume.ahk, Undo:pause.ahk
These aren't strictly required, but without them the PC may not stay asleep.
-
Stop random wakes: keep magic-packet wake (so Wake-on-LAN still works), turn off pattern-match wake:
# find your adapter name first: Get-NetAdapterPowerManagement Set-NetAdapterPowerManagement -Name "Ethernet" -WakeOnPattern Disabled
Check what woke it last with
powercfg /lastwake. -
Prevent
hibernate(S4) if you prefer to always quick wake host PC: by default Windows promotes S3 -> S4 after an idle timeout, so a long disconnect can silently fall into hibernate. Set "Hibernate after" to Never to stay in the power state you chose:powercfg /change hibernate-timeout-ac 0
Disable Fast Startup too. Confirm S3 is available with
powercfg /a. If you choose to keep hibernate on, Wake-on-LAN can take about 45 seconds for a full reconnect. This all boils down to personal preference. -
Set your power button to sleep/hibernate In the event that you accidentally wake your host pc with a mouse or keyboard, the game is still frozen, but won't allow your PC to sleep again. pressing the power button to sleep is a quick remedy for these events to sleep it again.
Everything is at the top of pause.ahk:
| Variable | Default | What it does |
|---|---|---|
PowerAction |
POWER_SLEEP |
Which power state to drop into on disconnect. See "Sleep vs hibernate" below. |
DebounceMs |
3000 |
How long to wait before sleeping, to check whether you quit instead of disconnecting. A quit shows up inside a second, so 3s is a comfortable margin. 1s or less may cause sleep-loop soft locks |
SleepOnQuit |
false |
true sleeps on a quit as well as a disconnect, and skips the wait above. |
SleepDelaySec |
0 |
Extra seconds to stay awake after a disconnect so you can reconnect from another device. 0 sleeps as soon as the disconnect is confirmed. |
ExcludedProcesses |
shells, Steam, launchers | Processes that are never frozen, so the script doesn't suspend Explorer or Playnite when they happen to be in focus. |
By default the host sleeps a few seconds after you disconnect. If you want to swap between handhelds and need a grace period, set:
global SleepDelaySec := 60The game still freezes right away, but the host waits a minute before sleeping. Reconnect from any device inside that minute and the game thaws and the sleep is cancelled.
Important
Don't raise DebounceMs for this: that timer is distinct for a reason. Because session quits fire both disconnect and quit events, there needs to be a delay to catch that sequence. Adjusting this without knowing what you're doing can cause a sleep-loop soft lock. You can force restart your computer, but you may lose your save state. SleepDelaySec exists as a separate variable for you to experiment with.
Set PowerAction at the top of pause.ahk:
| Value | State | Trade-off |
|---|---|---|
POWER_SLEEP |
S3 | ~3W, wakes in ~2s, state held in powered RAM. Default. Requires the host to stay plugged in and not fall through to S4 (see host setup #2). |
POWER_HIBERNATE |
S4 | ~0W, survives power loss, and wakes via Wake-on-LAN from a full power-off. Powers the discrete GPU down. Requires powercfg /hibernate on (otherwise it silently falls back to S3). |
POWER_NONE |
- | Do the freeze but change no power state (useful for testing). |
Missing-PID error on resume. The game crashed sometime during the sleep/wake cycle, so resume can't find its PID (the process is already gone) and reports the error. The common cause is a GPU driver timeout on resume that a fragile game doesn't survive, not the freeze itself. See "Sleep vs hibernate" for the caveat and the host-side fix.
I woke the PC by hand and the game is frozen. Run resume.ahk (keep a desktop shortcut for exactly this). It releases the process from suspend.
The PC slept when I quit the session. Two possible causes. First, resume.ahk may not be on the Command Preparations Undo slot, or may be pointing at a path that doesn't exist; without it, pause.ahk can't tell a quit from a disconnect. Second, SleepOnQuit may be set to true in pause.ahk, which makes a quit sleep the host on purpose; set it back to false if you only want disconnects to sleep.
The PC won't stay asleep, or wakes right after sleeping. That's Wake on Pattern Match on your network card. See the host setup above.
I want the PC to sleep on quit too, not just on disconnect. Set SleepOnQuit := true at the top of pause.ahk. By default it's false, so a quit leaves the host awake and only a disconnect sleeps it.
Forza Horizon Keeps crashing on wake I know. I have no fix.
A special thanks to ClassicOldSong for pioneering the original script. Without his script and Apollo plumbing, I never would have even considered this as a solution. All work here is heavily influenced by his original solution.