docs » hs.window
Inspect/manipulate windows
Notes:
- See
hs.screen
andhs.geometry
for more information on how Hammerspoon uses window/screen frames and coordinates
- Variables - Configurable values
- animationDuration
- setFrameCorrectness
- Functions - API calls offered directly by the extension
- allWindows
- desktop
- invisibleWindows
- list
- minimizedWindows
- orderedWindows
- setShadows
- snapshotForID
- timeout
- visibleWindows
- Constructors - API calls which return an object, typically one that offers API methods
- find
- focusedWindow
- frontmostWindow
- get
- Methods - API calls which can only be made on an object returned by a constructor
- application
- becomeMain
- centerOnScreen
- close
- focus
- focusTab
- focusWindowEast
- focusWindowNorth
- focusWindowSouth
- focusWindowWest
- frame
- id
- isFullScreen
- isMaximizable
- isMinimized
- isStandard
- isVisible
- maximize
- minimize
- move
- moveOneScreenEast
- moveOneScreenNorth
- moveOneScreenSouth
- moveOneScreenWest
- moveToScreen
- moveToUnit
- otherWindowsAllScreens
- otherWindowsSameScreen
- raise
- role
- screen
- sendToBack
- setFrame
- setFrameInScreenBounds
- setFrameWithWorkarounds
- setFullScreen
- setSize
- setTopLeft
- size
- snapshot
- subrole
- tabCount
- title
- toggleFullScreen
- toggleZoom
- topLeft
- unminimize
- windowsToEast
- windowsToNorth
- windowsToSouth
- windowsToWest
- zoomButtonRect
Signature | 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. |
Signature | hs.window.setFrameCorrectness |
---|---|
Type | Variable |
Description | Using hs.window:setFrame() in some cases does not work as expected: namely, the bottom (or Dock) edge, and edges between screens, might |
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.list(allWindows) -> table |
---|---|
Type | Function |
Description | Gets a table containing all the window data retrieved from CGWindowListCreate . |
Parameters |
|
Returns |
|
Notes |
|
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 hs.image object |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.window.timeout(value) -> boolean |
---|---|
Type | Function |
Description | Sets the timeout value used in the accessibility API. |
Parameters |
|
Returns |
|
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 |
|
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 hs.application object the window belongs to |
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 |
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) |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.window:focusWindowSouth([candidateWindows[, frontmost[, strict]]]) -> boolean |
---|---|
Type | Method |
Description | Focuses the nearest possible window to the south (i.e. down) |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.window:focusWindowWest([candidateWindows[, frontmost[, strict]]]) -> boolean |
---|---|
Type | Method |
Description | Focuses the nearest possible window to the west (i.e. left) |
Parameters |
|
Returns |
|
Notes |
|
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:isMaximizable() -> bool or nil |
---|---|
Type | Method |
Description | Determines if a window is maximizable |
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) |
Parameters |
|
Returns |
|
Signature | hs.window:moveOneScreenSouth([noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window one screen south (i.e. down) |
Parameters |
|
Returns |
|
Signature | hs.window:moveOneScreenWest([noResize, ensureInScreenBounds][, duration]) -> hs.window object |
---|---|
Type | Method |
Description | Moves the window one screen west (i.e. left) |
Parameters |
|
Returns |
|
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 |
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 hs.window.setFrameCorrectness |
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 hs.image object |
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. |
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 |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.window:windowsToSouth([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets all windows to the south of this window |
Parameters |
|
Returns |
|
Notes |
|
Signature | hs.window:windowsToWest([candidateWindows[, frontmost[, strict]]]) -> list of hs.window objects |
---|---|
Type | Method |
Description | Gets all windows to the west of this window |
Parameters |
|
Returns |
|
Notes |
|
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 |
|