QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: hanness on December 15, 2021, 07:36:38 am
-
I have a QB64 program that can take several hours to run. Is there anything that I can put in the code to prevent Windows from going to sleep while the program is running?
I don't want to have to modify my sleep settings every time I run the program. My preference would be to simply have some sort of code within the program that tells Windows not to go to sleep until told otherwise.
-
I think there is a way to do this with API but I would have to do some digging.
-
Simplest way is to just simulate a mouse click onto your program screen every so often.
http://www.qb64.org/wiki/SCREENCLICK
Or _MOUSEMOVE... Just move the mouse a single pixel on the screen. http://www.qb64.org/wiki/MOUSEMOVE
-
I've seen code in other languages that use this:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate
But the _MOUSEMOVE that Steve mentions sounds like an easier soulution. Perhaps setup a TIMER/GOSUB to do it every 60 seconds, like ON TIMER (60) GOSUB StayAwake
- Dav
-
Thanks for the responses. Much appreciated.