Documentation
¶
Index ¶
- Constants
- func AddMessageHandler(hwnd Hwnd, messageHandler *MessageHandler)
- func CharToVK(char rune) int32
- func DigitToVK(digit int) int32
- func DispatchMessage(msg *Message) bool
- func EnumWindows(callback WinEnumProc) error
- func FunctionToVK(index int) int32
- func GetCursorPos() (x int, y int)
- func GetMessage(msg *Message) bool
- func GetMessagePos() (x int, y int)
- func GetModuleBaseName(processHandle uintptr) string
- func GetModuleHandle(moduleName *string) uintptr
- func GetWindowLong(hwnd Hwnd, index int) (int, error)
- func GetWindowRect(hwnd Hwnd, rect *Rect) bool
- func GetWindowText(hwnd Hwnd) (string, error)
- func GetWindowThreadProcessID(hwnd Hwnd) int32
- func MessageBox(title string, description string) uintptr
- func MoveWindow(hwnd Hwnd, x int, y int, nWidth int, nHeight int) bool
- func NumToVK(index int) int32
- func OpenProcess(processID int32) (uintptr, error)
- func RegisterHotVkey(id int, vkey int32, alt bool, ctrl bool, shift bool, win bool) bool
- func RegisterHotkey(id int, key rune, alt bool, ctrl bool, shift bool, win bool) bool
- func SendMessage(hwnd Hwnd, msg uint, wParam Wparam, lParam LParam) int
- func SetForegroundWindow(hwnd Hwnd)
- func SetWindowText(hwnd Hwnd, title string) bool
- func ShowWindow(hwnd Hwnd) error
- func UnregisterHotVkey(id int) bool
- type HMenu
- type Hwnd
- type Icon
- type LParam
- type Menu
- type Message
- type MessageHandler
- type Notification
- type Point
- type PopupMenu
- type Rect
- type WinEnumProc
- type Wparam
Constants ¶
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 )
const ( IMAGE_ICON = 1 LR_LOADFROMFILE = 0x00000010 LR_DEFAULTSIZE = 0x00000040 )
const ( MF_POPUP = 0x00000010 MF_SEPARATOR = 0x00000800 MF_CHECKED = 0x00000008 MF_UNCHECKED = 0x0 WM_COMMAND = 0x0111 )
const ( NIM_ADD = 0 NIM_MODIFY = 1 NIM_DELETE = 2 )
const ( PROCESS_QUERY_INFORMATION = 0x0400 PROCESS_VM_READ = 0x0010 READ_CONTROL = 0x00020000 )
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 DispatchMessage ¶
DispatchMessage will forward messages to the corresponding windows
func EnumWindows ¶
func EnumWindows(callback WinEnumProc) error
EnumWindows enumerates all active windows
func FunctionToVK ¶
FunctionToVK returns the virtual key for the given function key index (valid for 1-12)
func GetCursorPos ¶
func GetMessage ¶
GetMessage retrieves a message from the windows message queue in a blocking way
func GetMessagePos ¶
GetMessagePos retrieves the coordinates of the last message
func GetModuleBaseName ¶
GetModuleBaseName will return the base name (e.g. the name of the executable) of the given process
func GetModuleHandle ¶
GetModuleHandle retrieves the handle to the given module
func GetWindowLong ¶
GetWindowLong will return window information
func GetWindowRect ¶
GetWindowRect returns then window rectangle of the given window
func GetWindowText ¶
GetWindowText will return the title of the window
func GetWindowThreadProcessID ¶
GetWindowThreadProcessID returns the process id of the window owning process
func MessageBox ¶
MessageBox will show a message box
func MoveWindow ¶
MoveWindow position the window with the given handle
func OpenProcess ¶
OpenProcess retrieves a handle to a process in read only mod with PROCESS_VM_READ, PROCESS_QUERY_INFORMATION and READ_CONTROL set
func RegisterHotVkey ¶
RegisterHotVkey will register a hotkey using its virtual key code
func RegisterHotkey ¶
RegisterHotkey will register the given key
func SendMessage ¶
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 ¶
SetWindowText sets the title bar of the window if it exists
func ShowWindow ¶
ShowWindow will active the window specified by the window handle by bringing it to the foreground
func UnregisterHotVkey ¶
UnregisterHotVkey will unregister the hotkey binding with the given id
Types ¶
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 Menu ¶
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
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 ¶
Notification provides functionality to control a motification icon
func AddNotification ¶
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 ¶
PopupMenu is a menu which can be opened anywhere on the screen like e.g. a context menu
func NewPopupMenu ¶
NewPopupMenu creates a new Windows popup menu
type Rect ¶
Rect defines a rectangle by coordinates of upper-left and lower-right corner
func GetClientRect ¶
GetClientRect returns the client area of a window
func GetWorkArea ¶
GetWorkArea returns the usable size minus taskbar and or app bars for the primary screen
type WinEnumProc ¶
WinEnumProc defines a callback function called during window enumeration