Browse the docs

Move or resize window

Moves, resizes, snaps, zooms, minimizes or full-screens the front window.

action the window

Keyboard Maestro: ManipulateWindow

Details #

Acts on the front window of the front app, or of the app named in app. Choose an action:

  • to snaps the window to a named place, given in to.

  • center centers the window on its screen.

  • move moves it. Give x and y, or a place in to.

  • resize changes its size. Give width and height.

  • zoom presses the window's green zoom button.

  • minimize minimizes it into the Dock.

  • fullscreen toggles full screen: it enters it, or leaves it if the window is already full screen.

  • moveBy, resizeBy and scale change the window relative to now: dx and dy, dwidth and dheight, or widthPercent and heightPercent. centerAt puts the window's middle at x, y.

  • unminimize, raise and close restore a minimized window, bring it forward, and press its close button.

By default the step acts on the app's focused window. Give window to pick another one: { "match": "contains", "value": "Notes" }. match is front, name, contains, regex, index (counting from 1), id or last (the window a previous window step used). With global on, x and y are measured from the top left of the whole screen area instead of the screen's visible area. When window, global or one of the actions in this paragraph is used, move needs both x and y.

The places for to, written exactly like this:

PlaceResult
leftHalfThe left half of the screen.
rightHalfThe right half.
topHalfThe top half.
bottomHalfThe bottom half.
maximizeFills the screen.
centerKeeps the window's size (shrunk if it is larger than the screen) and centers it.
nextDisplayMoves it to the next display, same size (shrunk to fit) and same relative position. With one display, nothing changes.

Places use the visible area of the screen the window is mostly on. That area excludes the menu bar and the Dock. For move, x and y are offsets from the top left corner of that visible area, in points. In the plain form you can give only one of them, and the other stays as it is.

For actions that place the window, the output holds the final x, y, width and height. For zoom, minimize, fullscreen and the other button actions it holds the action.

Parameters #

ParameterTypeRequiredValuesWhat it does
actionone ofYesmove resize zoom minimize fullscreen center to moveBy resizeBy scale centerAt unminimize raise closeRequired. One of move, resize, zoom, minimize, fullscreen, center, to, moveBy, resizeBy, scale, centerAt, unminimize, raise, close.
apptextThe app, by bundle id or name. Defaults to the front app.
dheightnumber
dwidthnumber, dheight: Size changes for resizeBy.
dxnumber, dy: Offsets for moveBy.
dynumber
globalyes / noMeasures x and y from the whole screen area. Off by default.
heightnumber
heightPercentnumber
totextA place from the table. Used by to and by move.
widthnumber, height: Size for resize. Give one or both.
widthPercentnumber, heightPercent: For scale. 100 keeps the size.
windowrecordmatch valueWhich window, as match and value. The default is the front one.
xnumber, y: Position offsets for move, or the middle point for centerAt.
ynumber

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Snap the front window to the left half (really moves the window)
Do
  1. Move the front window to the left half
Open in Switchboard to try it
Make the front window 900 by 600 and center it (really moves the window)
Do
  1. Resize the front window to 900 × 600
  2. Center the front window
Open in Switchboard to try it

Gotchas #

  • Some windows have a fixed size or position. The step fails with "the window can't be moved".

  • Apps may clamp a size to their own minimum.

  • After Activate app, an app's window may not exist yet. Wait for it with Wait.

  • If an unknown place is given, the step fails and lists the valid names.

See also #

Close window, Activate app, Wait