fun computer limitation which I know is true in Windows but is probably true in all OSes: you cannot catch an event for pressing the power button.
to clarify: you can catch an event for the machine beginning to shut down, but that's an OS process. you only get that long, long after it's started, and by that point taking action has limited value. the best thing you can do is try to interrupt the shutdown, but the problem is, when windows (and probably all OSes) starts the shutdown process, it tells everything to exit simultaneously, so even if you abort, damage will almost certainly still be done.
what i want is for the power button to sound an alarm if its pressed, so i know if udon (or philippe) is standing on it. because, yeah, I could set it to "do nothing" in windows, but then I wouldn't know there's a soft kitty paw on the button until the motherboard unceremoniously powers off the machine, making things even worse. but you can't catch this event unless you allow windows to begin a shutdown, and the problem is, that's a traumatic process to the computer.
last night my stream died, not because udon successfully shut off the machine, and not because OBS actually closed as requested, but because it crashed when it tried to interrupt the shutdown process. so, this has to be a "never event": the shutdown process can never be allowed to begin during a critical moment, but under the constraints of windows, there's no way to safeguard against that without also disabling the ability to find out that it's been pressed.
there are two solutions:
-
apparently other people have had the idea of changing the power button to suspend instead of shut down, and then using a program to catch and interrupt that. smart! while suspending is certainly not ideal, it's much less harrowing to your software; windows doesn't fire off a "oh shit oh shit the ship is going down" message to all your programs, and thus they have no opportunity to shit the bed with rarely-tested code. as long as whatever you use to catch and interrupt suspending succeeds, the rest of your programs will be completely unbothered; and if it does fail, going to suspend and coming back out is still less destructive than a shutdown

