Documentation
¶
Index ¶
- Constants
- Variables
- func AddAppOnKeyPress(keyCode int)
- func CreateWinEventHook() win.HWINEVENTHOOK
- func EnumWindowsCallback(hwnd syscall.Handle, lParam uintptr) uintptr
- func ForegroundWindowEvent(hWinEventHook win.HWINEVENTHOOK, event uint32, hwnd win.HWND, idObject int32, ...) uintptr
- func GetForegroundWindow() uintptr
- func GetWindowByProcessID(pid uint32) syscall.Handle
- func GetWindowText(hwnd uintptr) string
- func MoveWindow(executable string)
- func WatchForegroundWindowChange()
- func WatchProcessStart()deprecated
- type RECT
- type WindowInfo
Constants ¶
const ( GWL_EXSTYLE = 0xFFFFFFFFFFFFFFEC // Offset for extended window styles GWL_STYLE = 0xFFFFFFFFFFFFFFF0 // Style for tool windows WS_POPUP = 0x00000000 WS_EX_TOOLWINDOW = 0x00000080 WS_VISIBLE = 0x10000000 WS_CAPTION = 0x00C00000 // Title bar WS_THICKFRAME = 0x00040000 // Resizable border SWP_NOZORDER = 0x0004 SWP_NOACTIVATE = 0x0010 WINEVENT_OUTOFCONTEXT = 0x0000 EVENT_SYSTEM_FOREGROUND = 0x0003 )
Variables ¶
var OpenWindows []WindowInfo
Functions ¶
func AddAppOnKeyPress ¶
func AddAppOnKeyPress(keyCode int)
TODO: name is misleading since it also removes apps and the hotkey thing is not super user friendly. AddAppOnKeyPress takes the keyCode and waits for the key to be pressed. When pressed, the currently focused window is taken and either added to list of managed applications or removed from it if it is already on the list. Should this fail, the case will be ignored and the function waits on the next keypress.
func CreateWinEventHook ¶ added in v0.2.0
func CreateWinEventHook() win.HWINEVENTHOOK
CreateWinEventHook sets up the SetWinEventHook for foreground window changes
func EnumWindowsCallback ¶
EnumWindowsCallback is the callback function for EnumWindows
This function uses the GetWindowTextW and GetWindowTextLengthW functions from winuser.h.
See https://learn.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-getwindowtextw and https://learn.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-getwindowtextlengthw
func ForegroundWindowEvent ¶ added in v0.2.0
func ForegroundWindowEvent(hWinEventHook win.HWINEVENTHOOK, event uint32, hwnd win.HWND, idObject int32, idChild int32, idEventThread uint32, dwmsEventTime uint32) uintptr
ForegroundWindowEvent is called when the foreground window changes
func GetForegroundWindow ¶
func GetForegroundWindow() uintptr
GetForegroundWindow gets the handle to the foreground window
This function uses the GetForegroundWindow function from winuser.h.
See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getforegroundwindow
func GetWindowByProcessID ¶
getWindowByProcessID tries to get the window beloging to the given PID. On success the handle of the window is returned otherwise the return value is 0.
This function uses the GetWindowThreadProcessId function from winuser.h.
See https://learn.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-getwindowthreadprocessid
func GetWindowText ¶
GetWindowText retrieves the text of the window identified by the handle
This function uses the GetWindowTextW function from winuser.h.
See https://learn.microsoft.com/de-de/windows/win32/api/winuser/nf-winuser-getwindowtextw
func MoveWindow ¶
func MoveWindow(executable string)
MoveWindow tries to find a window handle for the given executable and sets the window style and dimensions for the window.
If the style and dimensions are already set, nothing is done.
func WatchForegroundWindowChange ¶
func WatchForegroundWindowChange()
WatchForegroundWindowChange starts listening for foreground window change events
func WatchProcessStart
deprecated
func WatchProcessStart()
Deprecated: This function is deprecated and may be removed in future versions. Use WatchForegroundWindowChange instead for improved performance and reliability.
WatchProcessStart scans all open (and visible) windows every five seconds and moves them if they are managed. While this provides some functionality, it has a severe performance impact. It is advised to use WatchForegroundWindowChange instead, which is more efficient. Consider transitioning to this new implementation.