github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/lib/terminal/hidden_windows.go (about)

     1  //go:build windows
     2  
     3  package terminal
     4  
     5  import (
     6  	"syscall"
     7  )
     8  
     9  // HideConsole hides the console window and activates another window
    10  func HideConsole() {
    11  	getConsoleWindow := syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow")
    12  	showWindow := syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow")
    13  	if getConsoleWindow.Find() == nil && showWindow.Find() == nil {
    14  		hwnd, _, _ := getConsoleWindow.Call()
    15  		if hwnd != 0 {
    16  			_, _, _ = showWindow.Call(hwnd, 0)
    17  		}
    18  	}
    19  }