Reworked the pause/resume scripts for Apollo/Artemis. Both scripts are still standalone, just drop them anywhere and point Apollo's Command Preparations at them.
Important
This is a personal refactor I'm sharing as-is. I'm not maintaining this, not accepting issues, not fielding feature requests. If it works for you, great. If not, the original gist is your best bet.
Warning
I'm figuring this out as I go. I've read through the original scripts, understood what they're doing, and made what I believe are improvements, but I haven't battle-tested these in every scenario Apollo can throw at them. The original scripts from the gist have been used by more people than these have (which is zero, at time of writing). Use these at your own risk, and if something breaks, the original scripts are right there to fall back to.
The big one. The original scripts assume pause always fires before resume, but Apollo doesn't guarantee that. When events come out of order, resume creates the lock file, then pause starts up and deletes it thinking it's stale. Game stays frozen.
Flipped the protocol so pause writes the PID into the lock file and resume reads it back, resumes the process directly, and deletes the file. If there's no lock file when resume runs, it just exits.
Swapped PROCESS_ALL_ACCESS for PROCESS_SUSPEND_RESUME (0x0800). Only permission actually needed. Full access can get denied on some processes, which might be behind some of the "suspend stopped working" reports on the gist.
The original helpers call MsgBox + ExitApp on failure, which triggers the cleanup handler, which calls ResumeProcess again. Now the helper just returns a boolean and the caller deals with it.
SuspendProcess and ResumeProcess were the same function with one string swapped. Merged them into CallNtProcessFunc(pid, funcName). Both scripts carry their own copy since Apollo invokes them as separate processes - pause.ahk on client disconnect, resume.ahk on reconnect (or as a global undo). They coordinate through the lock file: pause writes the game's PID into it, resume reads it back out, resumes the process, and deletes the file to signal pause that it can exit.
Also fixed a handle leak in here. The original code doesn't close the process handle if GetModuleHandle or GetProcAddress fails. OS cleans it up anyway on exit, but still.
- Process name lookup uses
"ahk_pid " pidexplicitly instead of relying on AHK's "last found window" which can go stale. - Added
steam.exeto the exclusion list per gist comments about Big Picture getting frozen. - Cleanup handler deletes the lock file on unexpected exit so the next run starts clean.