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
xandy, or a place into.resize changes its size. Give
widthandheight.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:
dxanddy,dwidthanddheight, orwidthPercentandheightPercent. centerAt puts the window's middle atx,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:
| Place | Result |
|---|---|
leftHalf | The left half of the screen. |
rightHalf | The right half. |
topHalf | The top half. |
bottomHalf | The bottom half. |
maximize | Fills the screen. |
center | Keeps the window's size (shrunk if it is larger than the screen) and centers it. |
nextDisplay | Moves 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 #
| Parameter | Type | Required | Values | What it does |
|---|---|---|---|---|
action | one of | Yes | move resize zoom minimize fullscreen center to moveBy resizeBy scale centerAt unminimize raise close | Required. One of move, resize, zoom, minimize, fullscreen, center, to, moveBy, resizeBy, scale, centerAt, unminimize, raise, close. |
app | text | The app, by bundle id or name. Defaults to the front app. | ||
dheight | number | |||
dwidth | number | , dheight: Size changes for resizeBy. | ||
dx | number | , dy: Offsets for moveBy. | ||
dy | number | |||
global | yes / no | Measures x and y from the whole screen area. Off by default. | ||
height | number | |||
heightPercent | number | |||
to | text | A place from the table. Used by to and by move. | ||
width | number | , height: Size for resize. Give one or both. | ||
widthPercent | number | , heightPercent: For scale. 100 keeps the size. | ||
window | record | match value | Which window, as match and value. The default is the front one. | |
x | number | , y: Position offsets for move, or the middle point for centerAt. | ||
y | number |
Every step also accepts label, onFailure, timeout and dryRunSafe.
Examples #
- Move the front window to the left half
- Resize the front window to 900 × 600
- Center the front window
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.