2021-09-09 20:25:25 +08:00
|
|
|
//go:build windows
|
2021-01-24 19:28:39 +08:00
|
|
|
|
|
|
|
package terminal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
// HideConsole hides the console window and activates another window
|
|
|
|
func HideConsole() {
|
|
|
|
getConsoleWindow := syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow")
|
|
|
|
showWindow := syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow")
|
|
|
|
if getConsoleWindow.Find() == nil && showWindow.Find() == nil {
|
|
|
|
hwnd, _, _ := getConsoleWindow.Call()
|
|
|
|
if hwnd != 0 {
|
2024-04-17 22:40:07 +08:00
|
|
|
_, _, _ = showWindow.Call(hwnd, 0)
|
2021-01-24 19:28:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|