winapi

package
v0.0.0-...-2dd5c5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2019 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HWND_TOP = 0

	MB_YESNOCANCEL = 0x00000003

	MOD_ALT      = 0x0001
	MOD_CONTROL  = 0x0002
	MOD_SHIFT    = 0x0004
	MOD_WIN      = 0x0008
	MOD_NOREPEAT = 0x4000

	SPI_GETWORKAREA = 0x0030

	VK_LEFT   = 0x25
	VK_UP     = 0x26
	VK_RIGHT  = 0x27
	VK_DOWN   = 0x28
	VK_PRIOR  = 0x21
	VK_NEXT   = 0x22
	VK_INSERT = 0x2D
	VK_DELETE = 0x2E
	VK_HOME   = 0x24
	VK_END    = 0x23
	VK_SPACE  = 0x20

	VK_NUMPAD0   = 0x60
	VK_MULTIPLY  = 0x6A
	VK_ADD       = 0x6B
	VK_SEPARATOR = 0x6C
	VK_SUBTRACT  = 0x6D
	VK_DECIMAL   = 0x6E
	VK_DIVIDE    = 0x6F

	VK_A = 0x41
	VK_Z = 0x5A

	VK_0 = 0x30

	VK_F1 = 0x70

	WM_QUIT          = 0x0012
	WM_CLOSE         = 0x0010
	WM_DESTROY       = 0x0002
	WM_HOTKEY        = 0x0312
	WM_LBUTTONDBLCLK = 0x203
	WM_RBUTTONUP     = 0x0205
	WM_RBUTTONDOWN   = 0x0204
)
View Source
const (
	IMAGE_ICON = 1

	LR_LOADFROMFILE = 0x00000010
	LR_DEFAULTSIZE  = 0x00000040
)
View Source
const (
	MF_POPUP     = 0x00000010
	MF_SEPARATOR = 0x00000800
	MF_CHECKED   = 0x00000008
	MF_UNCHECKED = 0x0
	WM_COMMAND   = 0x0111
)
View Source
const (
	NIM_ADD    = 0
	NIM_MODIFY = 1
	NIM_DELETE = 2
)
View Source
const (
	PROCESS_QUERY_INFORMATION = 0x0400
	PROCESS_VM_READ           = 0x0010
	READ_CONTROL              = 0x00020000
)
View Source
const (
	GWL_EXSTYLE = -20
	GWL_STYLE   = -16
)

Variables

This section is empty.

Functions

func AddMessageHandler

func AddMessageHandler(hwnd Hwnd, messageHandler *MessageHandler)

AddMessageHandler will add a message handler to the given window

func CharToVK

func CharToVK(char rune) int32

CharToVK converts a rune to a virtual key (valid for a-z)

func DigitToVK

func DigitToVK(digit int) int32

DigitToVK returns the virtual key for the given digits (valid for 0-9)

func DispatchMessage

func DispatchMessage(msg *Message) bool

DispatchMessage will forward messages to the corresponding windows

func EnumWindows

func EnumWindows(callback WinEnumProc) error

EnumWindows enumerates all active windows

func FunctionToVK

func FunctionToVK(index int) int32

FunctionToVK returns the virtual key for the given function key index (valid for 1-12)

func GetCursorPos

func GetCursorPos() (x int, y int)

func GetMessage

func GetMessage(msg *Message) bool

GetMessage retrieves a message from the windows message queue in a blocking way

func GetMessagePos

func GetMessagePos() (x int, y int)

GetMessagePos retrieves the coordinates of the last message

func GetModuleBaseName

func GetModuleBaseName(processHandle uintptr) string

GetModuleBaseName will return the base name (e.g. the name of the executable) of the given process

func GetModuleHandle

func GetModuleHandle(moduleName *string) uintptr

GetModuleHandle retrieves the handle to the given module

func GetWindowLong

func GetWindowLong(hwnd Hwnd, index int) (int, error)

GetWindowLong will return window information

func GetWindowRect

func GetWindowRect(hwnd Hwnd, rect *Rect) bool

GetWindowRect returns then window rectangle of the given window

func GetWindowText

func GetWindowText(hwnd Hwnd) (string, error)

GetWindowText will return the title of the window

func GetWindowThreadProcessID

func GetWindowThreadProcessID(hwnd Hwnd) int32

GetWindowThreadProcessID returns the process id of the window owning process

func MessageBox

func MessageBox(title string, description string) uintptr

MessageBox will show a message box

func MoveWindow

func MoveWindow(hwnd Hwnd, x int, y int, nWidth int, nHeight int) bool

MoveWindow position the window with the given handle

func NumToVK

func NumToVK(index int) int32

NumToVK returns the virtual key for the given num key index (valid for 0-9)

func OpenProcess

func OpenProcess(processID int32) (uintptr, error)

OpenProcess retrieves a handle to a process in read only mod with PROCESS_VM_READ, PROCESS_QUERY_INFORMATION and READ_CONTROL set

func RegisterHotVkey

func RegisterHotVkey(id int, vkey int32, alt bool, ctrl bool, shift bool, win bool) bool

RegisterHotVkey will register a hotkey using its virtual key code

func RegisterHotkey

func RegisterHotkey(id int, key rune, alt bool, ctrl bool, shift bool, win bool) bool

RegisterHotkey will register the given key

func SendMessage

func SendMessage(hwnd Hwnd, msg uint, wParam Wparam, lParam LParam) int

SendMessage will send a message synchronously to the specified window

func SetForegroundWindow

func SetForegroundWindow(hwnd Hwnd)

SetForegroundWindow brings a window to the front

func SetWindowText

func SetWindowText(hwnd Hwnd, title string) bool

SetWindowText sets the title bar of the window if it exists

func ShowWindow

func ShowWindow(hwnd Hwnd) error

ShowWindow will active the window specified by the window handle by bringing it to the foreground

func UnregisterHotVkey

func UnregisterHotVkey(id int) bool

UnregisterHotVkey will unregister the hotkey binding with the given id

Types

type HMenu

type HMenu uintptr

HMenu describes a handle to a menu

type Hwnd

type Hwnd uintptr

Hwnd defines a handle for a window

func CreateInactiveWindow

func CreateInactiveWindow(name string, x int, y int, width int, height int, messageHandlers ...*MessageHandler) (Hwnd, error)

CreateInactiveWindow will create a basic window which is not active by default and not visible inside the taskbar it will however still receive events, like e.g. shell_notifiy icon event

func GetForegroundWindow

func GetForegroundWindow() Hwnd

GetForegroundWindow retrieves the handle of the currently actrive foreground window

type Icon

type Icon interface {
	// contains filtered or unexported methods
}

func NewIcon

func NewIcon(fileName string) (Icon, error)

NewIcon create a new icon from the given file

type LParam

type LParam uintptr
type Menu interface {
	Set(hwnd Hwnd) error
	Insert(position uint, flags uint, id uint, label string) error
	Modify(position uint, flags uint, id uint, label string) error
	InsertSeparator() error
	InsertAtParent(position uint, flags uint, parent Menu, label string) error
	Destroy() error
	// contains filtered or unexported methods
}

Menu allows controlling a windows menu

func NewMenu

func NewMenu() (Menu, error)

NewMenu creates a new Windows menu

type Message

type Message struct {
	Hwnd    Hwnd
	Message uint
	WParam  uintptr
	LParam  uintptr
	Time    uint32
	Point   Point
}

Message defines a windows message queue event

type MessageHandler

type MessageHandler struct {
	// contains filtered or unexported fields
}

MessageHandler can be used to add a custom handler for a specific window or application message to the window event loop

func NewMessageHandler

func NewMessageHandler(msgID uint, onEvent func(hwnd Hwnd, wParam Wparam, lParam LParam) bool) *MessageHandler

NewMessageHandler creates a new handler object initializing it for correct use

type Notification

type Notification interface {
	SetIcon(icon Icon) error
	Remove() error
}

Notification provides functionality to control a motification icon

func AddNotification

func AddNotification(hwnd Hwnd, id int, callbackMsg int, icon Icon) (Notification, error)

AddNotification adds a notification element to the notification area

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point defines a position of e.g. a window

type PopupMenu

type PopupMenu interface {
	Menu
	Track(flags uint, x int, y int, hwnd Hwnd) error
}

PopupMenu is a menu which can be opened anywhere on the screen like e.g. a context menu

func NewPopupMenu

func NewPopupMenu() (PopupMenu, error)

NewPopupMenu creates a new Windows popup menu

type Rect

type Rect struct {
	Left   int32
	Top    int32
	Right  int32
	Bottom int32
}

Rect defines a rectangle by coordinates of upper-left and lower-right corner

func BorderEx

func BorderEx(hwnd Hwnd) (*Rect, error)

BorderEx returns the width of the drop shadow border

func GetClientRect

func GetClientRect(hwnd Hwnd) (*Rect, error)

GetClientRect returns the client area of a window

func GetWorkArea

func GetWorkArea() (*Rect, bool)

GetWorkArea returns the usable size minus taskbar and or app bars for the primary screen

func (*Rect) Height

func (rect *Rect) Height() int32

Height returns the width of the rectangle

func (*Rect) String

func (rect *Rect) String() string

func (*Rect) Width

func (rect *Rect) Width() int32

Width returns the width of the rectangle

type WinEnumProc

type WinEnumProc func(hwnd Hwnd, lParam LParam) uintptr

WinEnumProc defines a callback function called during window enumeration

type Wparam

type Wparam uintptr

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL