Documentation
¶
Overview ¶
Package win32 provides Windows API bindings using purego/syscall, eliminating the need for cgo.
Index ¶
- Constants
- func CaptureScreen(x, y, w, h int32) ([]byte, int, int)
- func CloseWindow(hwnd uintptr) bool
- func EnumWindows(callback uintptr, lParam uintptr) bool
- func FindWindowByName(name string) uintptr
- func FindWindowByPID(pid uint32) uintptr
- func GetActiveWindow() uintptr
- func GetCursorPos(pt *POINT) bool
- func GetDesktopWindow() uintptr
- func GetDpiForWindow(hwnd uintptr) uint32
- func GetForegroundWindow() uintptr
- func GetNumDisplays() int
- func GetPixelColor(x, y int32) uint32
- func GetScreenSize() (int32, int32)
- func GetSystemMetricsForDpi(idx int32, dpi uint32) int32
- func GetWindowText(hwnd uintptr) string
- func GetWindowThreadProcessId(hwnd uintptr) uint32
- func IsWindow(hwnd uintptr) bool
- func KeyCodeForChar(char byte) uint32
- func MapVirtualKey(uCode, uMapType uint32) uint32
- func MoveMouse(x, y int32) int
- func PostCloseMessage(hwnd uintptr)
- func ScrollMouse(x, y int)
- func SendInput(nInputs uint32, pInputs unsafe.Pointer, cbSize int32) uint32
- func SetActiveWindowHwnd(hwnd uintptr) uintptr
- func SetCursorPos(x, y int32) bool
- func SetFocusHwnd(hwnd uintptr) uintptr
- func SetForegroundWindow(hwnd uintptr) bool
- func SetWindowPlacement(hwnd uintptr, wp *WINDOWPLACEMENT) bool
- func ShowWindow(hwnd uintptr, cmd int32) bool
- func ToggleKeyCode(keyCode uint32, down bool, flags uint64, pid uintptr) int
- func ToggleMouse(down bool, button uint16) int
- func UnicodeType(char uint32, pid uintptr, isPid int8)
- type BITMAPINFOHEADER
- type INPUT
- type KEYBDINPUT
- type MOUSEINPUT
- type POINT
- type RECT
- type WINDOWPLACEMENT
Constants ¶
const ( INPUT_MOUSE = 0 INPUT_KEYBOARD = 1 MOUSEEVENTF_MOVE = 0x0001 MOUSEEVENTF_LEFTDOWN = 0x0002 MOUSEEVENTF_LEFTUP = 0x0004 MOUSEEVENTF_RIGHTDOWN = 0x0008 MOUSEEVENTF_RIGHTUP = 0x0010 MOUSEEVENTF_MIDDLEDOWN = 0x0020 MOUSEEVENTF_MIDDLEUP = 0x0040 MOUSEEVENTF_WHEEL = 0x0800 MOUSEEVENTF_HWHEEL = 0x01000 KEYEVENTF_KEYUP = 0x0002 KEYEVENTF_UNICODE = 0x0004 KEYEVENTF_SCANCODE = 0x0008 WHEEL_DELTA = 120 MAPVK_VK_TO_VSC = 0 MAPVK_VSC_TO_VK = 1 MAPVK_VK_TO_CHAR = 2 MAPVK_VSC_TO_VK_EX = 3 VK_LSHIFT = 0xA0 VK_RSHIFT = 0xA1 VK_LCONTROL = 0xA2 VK_RCONTROL = 0xA3 VK_LMENU = 0xA4 VK_RMENU = 0xA5 VK_LWIN = 0x5B VK_RWIN = 0x5C SW_MINIMIZE = 6 SW_MAXIMIZE = 3 SW_RESTORE = 9 GWL_STYLE = -16 WS_MAXIMIZE = 0x01000000 WS_MINIMIZE = 0x20000000 WM_CLOSE = 0x0010 WM_GETTEXT = 0x000D WM_GETTEXTLENGTH = 0x000E DIB_RGB_COLORS = 0 SRCCOPY = 0x00CC0020 BI_RGB = 0 GWL_WNDPROC = -4 WM_KEYDOWN = 0x0100 WM_KEYUP = 0x0101 WM_CHAR = 0x0102 )
Windows constants
Variables ¶
This section is empty.
Functions ¶
func CaptureScreen ¶
CaptureScreen captures a screen region and returns pixel data (BGRA format) The caller is responsible for freeing the returned buffer.
func EnumWindows ¶
EnumWindows enumerates all top-level windows
func FindWindowByName ¶
FindWindowByName finds a window by name
func FindWindowByPID ¶
FindWindowByPID finds a window by process ID
func GetDpiForWindow ¶
GetDpiForWindow gets DPI for a window
func GetForegroundWindow ¶
func GetForegroundWindow() uintptr
GetForegroundWindow returns the foreground window handle
func GetPixelColor ¶
GetPixelColor gets the pixel color at (x, y) as RGB hex
func GetSystemMetricsForDpi ¶
GetSystemMetricsForDpi gets system metrics for DPI
func GetWindowThreadProcessId ¶
GetWindowThreadProcessId gets the thread and process id for a window
func KeyCodeForChar ¶
KeyCodeForChar returns the virtual key code for a character
func MapVirtualKey ¶
MapVirtualKey maps a virtual key code
func PostCloseMessage ¶
func PostCloseMessage(hwnd uintptr)
PostCloseMessage posts WM_CLOSE to a window
func SetActiveWindowHwnd ¶
SetActiveWindowHwnd sets the active window
func SetForegroundWindow ¶
SetForegroundWindow sets the foreground window
func SetWindowPlacement ¶
func SetWindowPlacement(hwnd uintptr, wp *WINDOWPLACEMENT) bool
SetWindowPlacement sets the window placement
func ShowWindow ¶
ShowWindow shows/hides/minimizes/maximizes a window
func ToggleKeyCode ¶
ToggleKeyCode sends a key down/up event
func ToggleMouse ¶
ToggleMouse toggles a mouse button (down or up)
func UnicodeType ¶
UnicodeType sends a unicode character
Types ¶
type BITMAPINFOHEADER ¶
type BITMAPINFOHEADER struct {
BiSize uint32
BiWidth int32
BiHeight int32
BiPlanes uint16
BiBitCount uint16
BiCompression uint32
BiSizeImage uint32
BiXPelsPerMeter int32
BiYPelsPerMeter int32
BiClrUsed uint32
BiClrImportant uint32
}
BITMAPINFOHEADER is the Windows BITMAPINFOHEADER structure
type KEYBDINPUT ¶
KEYBDINPUT is the Windows KEYBDINPUT structure
type MOUSEINPUT ¶
type MOUSEINPUT struct {
DX int32
DY int32
MouseData uint32
DwFlags uint32
Time uint32
DwExtraInfo uintptr
}
MOUSEINPUT is the Windows MOUSEINPUT structure
type RECT ¶
RECT is the Windows RECT structure
func GetClientRect ¶
GetClientRect gets the window client rectangle
func GetWindowRect ¶
GetWindowRect gets the window rectangle
type WINDOWPLACEMENT ¶
type WINDOWPLACEMENT struct {
Length uint32
Flags uint32
ShowCmd uint32
PtMinPosition POINT
PtMaxPosition POINT
RcNormalPosition RECT
}
WINDOWPLACEMENT is the Windows WINDOWPLACEMENT structure
func GetWindowPlacement ¶
func GetWindowPlacement(hwnd uintptr) (WINDOWPLACEMENT, bool)
GetWindowPlacement gets the window placement