//go:build windows package win32 import ( "unsafe" ) var ( procGetWindowRect = user32.NewProc("GetWindowRect") ) type rect struct { Left, Top, Right, Bottom int32 } // GetWindowSize returns the width and height of the given window in pixels. func GetWindowSize(hwnd uintptr) (width, height int, ok bool) { var r rect ret, _, _ := procGetWindowRect.Call(hwnd, uintptr(unsafe.Pointer(&r))) if ret == 0 { return 0, 0, false } return int(r.Right - r.Left), int(r.Bottom - r.Top), true }