Some Windows API window functions

Here hWnd is window handle. Use function win to get it. For controls, use child or id.

 

IsWindow(hWnd) returns 1 if the handle is valid window handle and the window is not destroyed.
IsZoomed(hWnd) returns 1 if window is maximized. See also max.
IsIconic(hWnd) returns 1 if window is minimized. See also min.
IsWindowVisible(hWnd) returns 1 if window is visible. See also hid.
IsWindowEnabled(hWnd) returns 1 if window is enabled.
EnableWindow(hWnd fEnable) enables (fEnable 1) or disables (fEnable 0) window.
MoveWindow(hWnd x y nWidth nHeight bRepaint) moves and resizes window. See also mov+.
SetWindowPos(hWnd hWndInsertAfter x y cx cy wFlags) moves and/or resizes and/or sets Z order, and/or more. For wFlags use SWP_ constants.
GetWindowRect(hWnd RECT*lpRect) get window dimensions. See also DpiGetWindowRect.
GetParent(hWnd) returns handle of direct parent window of child window.
GetAncestor(hWnd gaFlags) returns handle of container window. gaFlags: 1 parent (the same as GetParent), 2 top-level parent, 3 top-level parent or owner.
WindowFromPoint(xPoint yPoint) returns handle of window or child window from point. See also win, child.

 

type POINT x y used to store point coordinates
type RECT left top right bottom used to store rectangle coordinates

 

You can use functions GetSystemMetrics and SystemParametersInfo to get various system parameters. These and other Windows API functions are documented in MSDN library.

 

Examples

 Toggle active window's maximized/restored state:
if(IsZoomed(win)) res; else max
 Display dimensions of active window:
RECT r; DpiGetWindowRect(win &r)
out "x=%i y=%i width=%i height=%i" r.left r.top r.right-r.left r.bottom-r.top
 Get the work area (the portion of the screen not obscured by the system taskbar or by application desktop toolbars): 
RECT r; SystemParametersInfo(SPI_GETWORKAREA 0 &r 0)