Browse the docs

window

Returns a coordinate or size of a window of the front app, in screen points.

Keyboard Maestro: WINDOW

Details #

window(coordinate, percent?) or window(which, coordinate, percent?) takes one to three arguments and returns a whole number.

  • coordinate is one of left, right, top, bottom, width, height, center, middle (short forms such as x, y, w, h also work).

  • which picks the window of the front app: empty text or front for the front window, a 1-based number (1 is the front window), or all or part of a window title. With no which, the front window is used.

  • percent gives the point that far across or down the window, as in screen.

Only ordinary on-screen windows of the front app are counted, front one first. Positions use the same origin as screens: the top left of the main display.

Parameters #

Takes 1 to 3 arguments. {{ window(text, b?, c?) }}

Examples #

windowCount() > 0 ? window("width") : 0
→ 0
windowCount() > 0 ? window("1", "center") : 0
→ 0

Gotchas #

  • A window that isn't there is an error: window() found no window '3' in the front app (1 open). With no windows to read it always is, so check windowCount() first.

  • An unknown coordinate is an error that lists the valid ones.

  • Only ordinary on-screen windows of the front app are searched, so a minimized or hidden window is not found.