fix(windows): prevent console window flash

- Centralize hidden-process setup per OS
- Hide console early to avoid startup flash
- Keep capture window off-screen and hidden
- Enable unified scheduler for watchdog task
- Force GUI subsystem in build script
This commit is contained in:
2026-09-01 23:25:06 +03:00
parent e74f74bc4e
commit cc2b1d049b
12 changed files with 103 additions and 36 deletions
+15
View File
@@ -26,6 +26,13 @@ const (
ctrlCloseEvent = 2
)
func init() {
// Must run before main: a console-subsystem build otherwise flashes a
// terminal during flag.Parse, which looks like a broken automation step.
ProtectFromConsoleClose()
HideConsole()
}
// HideConsole hides any console window and detaches from it.
func HideConsole() {
hwnd, _, _ := procGetConsoleWindow.Call()
@@ -56,6 +63,14 @@ func ProtectFromConsoleClose() {
_, _, _ = procSetConsoleCtrl.Call(consoleCtrlCallback, 1)
}
// AllowConsoleKill restores default Ctrl+C handling for -foreground.
func AllowConsoleKill() {
if consoleCtrlCallback == 0 {
return
}
_, _, _ = procSetConsoleCtrl.Call(consoleCtrlCallback, 0)
}
func consoleCtrlHandler(ctrlType uintptr) uintptr {
switch uint32(ctrlType) {
case ctrlCEvent, ctrlBreakEvent, ctrlCloseEvent: