master
go 18 lines 447 Bytes
Raw
1 package util
2
3 import "golang.org/x/sys/windows"
4
5 func InsideGUI() bool {
6 conhostInfo := &windows.ConsoleScreenBufferInfo{}
7 if err := windows.GetConsoleScreenBufferInfo(windows.Stdout, conhostInfo); err != nil {
8 return false
9 }
10
11 if (conhostInfo.CursorPosition.X | conhostInfo.CursorPosition.Y) == 0 {
12 // console cursor has not moved prior to our execution
13 // high probability that we're not in a terminal
14 return true
15 }
16
17 return false
18 }