dt_automate/vendor/github.com/kbinani/screenshot/windows_lt1.21.go
2025-02-19 18:30:19 +08:00

31 lines
686 B
Go

//go:build windows && !go1.21
package screenshot
import (
"image"
"syscall"
"unsafe"
"github.com/lxn/win"
)
func NumActiveDisplays() int {
var count int
count = 0
ptr := unsafe.Pointer(&count)
enumDisplayMonitors(win.HDC(0), nil, syscall.NewCallback(countupMonitorCallback), uintptr(ptr))
return count
}
func GetDisplayBounds(displayIndex int) image.Rectangle {
var ctx getMonitorBoundsContext
ctx.Index = displayIndex
ctx.Count = 0
ptr := unsafe.Pointer(&ctx)
enumDisplayMonitors(win.HDC(0), nil, syscall.NewCallback(getMonitorBoundsCallback), uintptr(ptr))
return image.Rect(
int(ctx.Rect.Left), int(ctx.Rect.Top),
int(ctx.Rect.Right), int(ctx.Rect.Bottom))
}