I've been poking at a way to prevent a PC or its display from going to sleep while my script is running, and then when the script is done, and is closed, it will no longer prevent sleep (ie return to normal behavior).
I ran across this blog https://den.dev/blog/caffeinate-windows/ which has a script to call the API used by media players (apparently).
A very simple version is this keepawake one https://gist.github.com/jamesfreeman959/231b068c3d1ed6557675f21c0e346a9c
Has anyone used either of these integrated into their own scripts (and not just to keep the machine awake for 'work purposes')? The first one seems to be pretty independent so im under where (or if) my script can be inserted to work with it. And I dont think it will work if I make it its own script and call it from my main script (as it will just sit there and wait).
The second... just feels weird or clunky to have to dump my entire script within its loop.
Or maybe im reading too much into both of these. Looking for input.