Fixed prevention of sleep.

This commit is contained in:
Anton Potekhin
2023-04-27 09:02:08 +03:00
parent 6f18ad7f29
commit 0673d3102e

View File

@@ -4,6 +4,7 @@
package main
import (
"runtime"
"syscall"
"time"
@@ -21,6 +22,8 @@ var pulseTime = 60 * time.Second
func Preconfig(kill bool) {
go func() {
// need work on one thread because SetThreadExecutionState sets flag to thread. We need set and clear flag for same thread.
runtime.LockOSThread()
// don't sleep/hibernate windows
kernel32 := syscall.NewLazyDLL("kernel32.dll")
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")