Inspect/manipulate windows
Notes:
hs.screen
and hs.geometry
for more information on how Hammerspoon uses window/screen frames and coordinatesSignature | hs.window.animationDuration (number) |
---|---|
Type | Variable |
Description | The default duration for animations, in seconds. Initial value is 0.2; set to 0 to disable animations. Usage:
|
Signature | hs.window.setFrameCorrectness |
---|---|
Type | Variable |
Description | Using Setting this variable to The default value is |
Signature | hs.window.allWindows() -> list of hs.window objects |
---|---|
Type | Function |
Description | Returns all windows Parameters:
Returns:
Notes:
|
Signature | hs.window.desktop() -> hs.window object |
---|---|
Type | Function |
Description | Returns the desktop "window" Parameters:
Returns:
Notes:
|
Signature | hs.window.invisibleWindows() -> list of hs.window objects |
---|---|
Type | Function |
Description | Gets all invisible windows Parameters:
Returns:
|
Signature | hs.window.minimizedWindows() -> list of hs.window objects |
---|---|
Type | Function |
Description | Gets all minimized windows Parameters:
Returns:
|
Signature | hs.window.orderedWindows() -> list of hs.window objects |
---|---|
Type | Function |
Description | Returns all visible windows, ordered from front to back Parameters:
Returns:
|
Signature | hs.window.setShadows(shadows) |
---|---|
Type | Function |
Description | Enables/Disables window shadows Parameters:
Returns:
Notes:
|
Signature | hs.window.snapshotForID(ID [, keepTransparency]) -> hs.image-object |
---|---|
Type | Function |
Description | Returns a snapshot of the window specified by the ID as an Parameters:
Returns:
Notes:
|
Signature | hs.window.visibleWindows() -> list of hs.window objects |
---|---|
Type | Function |
Description | Gets all visible windows Parameters:
Returns:
|
Signature | hs.window.find(hint) -> hs.window object(s) |
---|---|
Type | Constructor |
Description | Finds windows Parameters:
Returns:
Notes:
Usage:
|
Signature | hs.window.focusedWindow() -> window |
---|---|
Type | Constructor |
Description | Returns the window that has keyboard/mouse focus Parameters:
Returns:
|
Signature | hs.window.frontmostWindow() -> hs.window object |
---|---|
Type | Constructor |
Description | Returns the focused window or, if no window has focus, the frontmost one Parameters:
Returns:
|
Signature | hs.window.get(hint) -> hs.window object |
---|---|
Type | Constructor |
Description | Gets a specific window Parameters:
Returns:
Notes:
|
Signature | hs.window:application() -> app or nil |
---|---|
Type | Method |
Description | Gets the Parameters:
Returns:
|
Signature | hs.window:becomeMain() -> window |
---|---|
Type | Method |
Description | Makes the window the main window of its application Parameters:
Returns:
Notes:
|
Signature | hs.window:centerOnScreen([screen][, ensureInScreenBounds][, duration]) --> hs.window object |
---|---|
Type | Method |
Description | Centers the window on a screen Parameters:
Returns:
|
Signature | hs.window:close() -> bool |
---|---|
Type | Method |
Description | Closes the window Parameters:
Returns:
|
Signature | hs.window:focus() -> hs.window object |
---|---|
Type | Method |
Description | Focuses the window Parameters:
Returns:
|
Signature | hs.window:focusTab(index) -> bool |
---|---|
Type | Method |
Description | Focuses the tab in the window's tab group at index, or the last tab if index is out of bounds. Returns true if a tab was pressed. Works with document tab groups and some app tabs, like Chrome and Safari. Parameters:
Returns:
|
Signature | hs.window:focusWindowEast([candidateWindows[, frontmost[, strict]]]) -> boolean |
---|---|
Type | Method |
Description | Focuses the nearest possible window to the east (i.e. right) Parameters:
Returns:
Notes:
|
Signature | hs.window:focusWindowNorth([candidateWindows[, frontmost[, strict]]]) -> boolean |
---|---|
Type | Method |
Description | Focuses the nearest possible window to the north (i.e. up) (See |
Signature | hs.window:focusWindowSouth([candidateWindows[, frontmost[, strict]]]) -> boolean |
---|---|
Type | Method |
Description | Focuses the nearest possible window to the south (i.e. down) (See |
Signature | hs.window:focusWindowWest([candidateWindows[, frontmost[, strict]]]) -> boolean |
---|---|
Type | Method |
Description | Focuses the nearest possible window to the west (i.e. left) (See |
Signature | hs.window:frame() -> hs.geometry rect |
---|---|
Type | Method |
Description | Gets the frame of the window in absolute coordinates Parameters:
Returns:
|
Signature | hs.window:id() -> number or nil |
---|---|
Type | Method |
Description | Gets the unique identifier of the window Parameters:
Returns:
|
Signature | hs.window:isFullScreen() -> bool or nil |
---|---|
Type | Method |
Description | Gets the fullscreen state of the window Parameters:
Returns:
|
Signature | hs.window:isMinimized() -> bool |
---|---|
Type | Method |
Description | Gets the minimized state of the window Parameters:
Returns:
|
Signature | hs.window:isStandard() -> bool |
---|---|
Type | Method |
Description | Determines if the window is a standard window Parameters:
Returns:
Notes:
|
Signature | hs.window:isVisible() -> boolean |
---|---|
Type | Method |
Description | Determines if a window is visible (i.e. not hidden and not minimized) Parameters:
Returns:
Notes:
|
Signature | hs.window:maximize([duration]) -> hs.window object |
---|---|
Type | Method |
Description | Maximizes the window Parameters:
Returns:
Notes:
|
Signature | hs.window:minimize() -> window |
---|---|
Type | Method |
Description | Minimizes the window Parameters:
Returns:
Notes:
|
Signature | hs.window:move(rect[, screen][, ensureInScreenBounds][, duration]) --> hs.window object |
---|---|
Type | Method |
Description | Moves the window Parameters:
Returns:
|
Signature | hs.window:moveOneScreenEast([noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window one screen east (i.e. right) Parameters:
Returns:
|
Signature | hs.window:moveOneScreenNorth([noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window one screen north (i.e. up) (See |
Signature | hs.window:moveOneScreenSouth([noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window one screen south (i.e. down) (See |
Signature | hs.window:moveOneScreenWest([noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window one screen west (i.e. left) (See |
Signature | hs.window:moveToScreen(screen[, noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window to a given screen, retaining its relative position and size Parameters:
Returns:
|
Signature | hs.window:moveToUnit(unitrect[, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves and resizes the window to occupy a given fraction of the screen Parameters:
Returns:
Notes:
|
Signature | hs.window:otherWindowsAllScreens() -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets every window except this one Parameters:
Returns:
|
Signature | hs.window:otherWindowsSameScreen() -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets other windows on the same screen Parameters:
Returns:
|
Signature | hs.window:raise() -> window |
---|---|
Type | Method |
Description | Brings a window to the front of the screen without focussing it Parameters:
Returns:
|
Signature | hs.window:role() -> string |
---|---|
Type | Method |
Description | Gets the role of the window Parameters:
Returns:
|
Signature | hs.window:screen() -> hs.screen object |
---|---|
Type | Method |
Description | Gets the screen which the window is on Parameters:
Returns:
|
Signature | hs.window:sendToBack() -> hs.window object |
---|---|
Type | Method |
Description | Sends the window to the back This method works by focusing all overlapping windows behind this one, front to back. If called on the focused window, this method will switch focus to the topmost window under this one; otherwise, the currently focused window will regain focus after this window has been sent to the back. Parameters:
Returns:
Notes:
|
Signature | hs.window:setFrame(rect[, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Sets the frame of the window in absolute coordinates Parameters:
Returns:
|
Signature | hs.window:setFrameInScreenBounds([rect][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Sets the frame of the window in absolute coordinates, possibly adjusted to ensure it is fully inside the screen Parameters:
Returns:
|
Signature | hs.window:setFrameWithWorkarounds(rect[, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Sets the frame of the window in absolute coordinates, using the additional workarounds described in Parameters:
Returns:
|
Signature | hs.window:setFullScreen(fullscreen) -> window |
---|---|
Type | Method |
Description | Sets the fullscreen state of the window Parameters:
Returns:
|
Signature | hs.window:setSize(size) -> window |
---|---|
Type | Method |
Description | Resizes the window Parameters:
Returns:
|
Signature | hs.window:setTopLeft(point) -> window |
---|---|
Type | Method |
Description | Moves the window to a given point Parameters:
Returns:
|
Signature | hs.window:size() -> size |
---|---|
Type | Method |
Description | Gets the size of the window Parameters:
Returns:
|
Signature | hs.window:snapshot([keepTransparency]) -> hs.image-object |
---|---|
Type | Method |
Description | Returns a snapshot of the window as an Parameters:
Returns:
Notes:
|
Signature | hs.window:subrole() -> string |
---|---|
Type | Method |
Description | Gets the subrole of the window Parameters:
Returns:
Notes:
|
Signature | hs.window:tabCount() -> number or nil |
---|---|
Type | Method |
Description | Gets the number of tabs in the window has, or nil if the window doesn't have tabs. Intended for use with the focusTab method, if this returns a number, then focusTab can switch between that many tabs. Parameters:
Returns:
|
Signature | hs.window:title() -> string |
---|---|
Type | Method |
Description | Gets the title of the window Parameters:
Returns:
|
Signature | hs.window:toggleFullScreen() -> hs.window object |
---|---|
Type | Method |
Description | Toggles the fullscreen state of the window Parameters:
Returns:
Notes:
|
Signature | hs.window:toggleZoom() -> window |
---|---|
Type | Method |
Description | Toggles the zoom state of the window (this is effectively equivalent to clicking the green maximize/fullscreen button at the top left of a window) Parameters:
Returns:
|
Signature | hs.window:topLeft() -> point |
---|---|
Type | Method |
Description | Gets the absolute co-ordinates of the top left of the window Parameters:
Returns:
|
Signature | hs.window:unminimize() -> window |
---|---|
Type | Method |
Description | Un-minimizes the window Parameters:
Returns:
|
Signature | hs.window:windowsToEast([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets all windows to the east of this window Parameters:
Returns:
Notes:
|
Signature | hs.window:windowsToNorth([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets all windows to the north of this window (See |
Signature | hs.window:windowsToSouth([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets all windows to the south of this window (See |
Signature | hs.window:windowsToWest([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets all windows to the west of this window (See |
Signature | hs.window:zoomButtonRect() -> rect-table or nil |
---|---|
Type | Method |
Description | Gets a rect-table for the location of the zoom button (the green button typically found at the top left of a window) Parameters:
Returns:
Notes:
|