hs.screen
and hs.geometry
for more information on how Hammerspoon uses window/screen frames and coordinateshs.window.animationDuration (number)
hs.window.setFrameCorrectness
hs.window:setFrame()
in some cases does not work as expected: namely, the bottom (or Dock) edge, and edges between screens, mighths.window.allWindows() -> list of hs.window objects
hs.window
objects representing all open windowsvisibleWindows()
, orderedWindows()
, get()
, find()
, and several more functions and methods in this and other modules make use of this function, so it is important to understand its limitationshs.window.filter
modulehs.window.filter
moduleDisplays have separate Spaces
is on (in System Preferences>Mission Control) the current Space is defined as the union of all currently visible Spaceshs.window.desktop()
to address it. (Note however that hs.application.get'Finder':allWindows()
will include the desktop in the returned list)hs.window.focusWindowSouth()
from a Chrome window would end up "focusing" its status bar, and therefore the proper window itself, seemingly resulting in a no-op. In order to avoid such surprises you can use the hs.window.filter
module, and more specifically the default windowfilter (hs.window.filter.default
) which filters out known cases of not-actual-windowshs.window.desktop() -> hs.window object
hs.window
object representing the desktop, or nil if Finder is not runningAXScrollArea
and no subrolehs.window.allWindows()
(and downstream uses)hs.window.invisibleWindows() -> list of hs.window objects
hs.window
objects representing all windows that are not visible as per hs.window:isVisible()
hs.window.list(allWindows) -> table
CGWindowListCreate
.true
is succesful otherwise false
if an error occured.hs.window.minimizedWindows() -> list of hs.window objects
hs.window
objects representing all windows that are minimized as per hs.window:isMinimized()
hs.window.orderedWindows() -> list of hs.window objects
hs.window
objects representing all visible windows, ordered from front to backhs.window.setShadows(shadows)
hs.window.snapshotForID(ID [, keepTransparency]) -> hs.image-object
hs.image
objecths.image
object of the window snapshot or nil if unable to create a snapshoths.window:snapshot()
hs.window.timeout(value) -> boolean
true
is succesful otherwise false
if an error occured.hs.window.visibleWindows() -> list of hs.window objects
hs.window
objects representing all windows that are visible as per hs.window:isVisible()
hs.window.find(hint) -> hs.window object(s)
hs.window:id()
string.find
) the window title as per hs.window:title()
(for convenience, the matching will be done on lowercased strings)nil
if none foundhs.window(hint)
hs.window.get
hs.window.filter
hs.window.focusedWindow() -> window
hs.window
object representing the currently focused windowhs.window.frontmostWindow() -> hs.window object
hs.window
object representing the frontmost window, or nil
if there are no visible windowshs.window.get(hint) -> hs.window object
hs.window:id()
hs.window:title()
nil
if not foundhs.window.find
and hs.application:getWindow()
hs.window:application() -> app or nil
hs.application
object the window belongs tohs.application
object representing the application that owns the window, or nil if an error occurredhs.window:becomeMain() -> window
hs.window
objecths.window.focus()
hs.window:centerOnScreen([screen][, ensureInScreenBounds][, duration]) --> hs.window object
hs.screen
object or argument for hs.screen.find
; if nil, use the screen the window is currently ontrue
, use setFrameInScreenBounds()
to ensure the resulting window frame is fully contained within the window's screenhs.window.animationDuration
hs.window
objecths.window:close() -> bool
hs.window:focus() -> hs.window object
hs.window
objecths.window:focusTab(index) -> bool
hs.window:focusWindowEast([candidateWindows[, frontmost[, strict]]]) -> boolean
true
if a window was found and focused, false
otherwise; nil
if the search couldn't take placecandidateWindows
, Hammerspoon will query for the list of all visible windows every time this method is called; this can be slow, and some undesired "windows" could be included (see the notes for hs.window.allWindows()
); consider using the equivalent methods in hs.window.filter
insteadhs.window:focusWindowNorth([candidateWindows[, frontmost[, strict]]]) -> boolean
true
if a window was found and focused, false
otherwise; nil
if the search couldn't take placecandidateWindows
, Hammerspoon will query for the list of all visible windows every time this method is called; this can be slow, and some undesired "windows" could be included (see the notes for hs.window.allWindows()
); consider using the equivalent methods in hs.window.filter
insteadhs.window:focusWindowSouth([candidateWindows[, frontmost[, strict]]]) -> boolean
true
if a window was found and focused, false
otherwise; nil
if the search couldn't take placecandidateWindows
, Hammerspoon will query for the list of all visible windows every time this method is called; this can be slow, and some undesired "windows" could be included (see the notes for hs.window.allWindows()
); consider using the equivalent methods in hs.window.filter
insteadhs.window:focusWindowWest([candidateWindows[, frontmost[, strict]]]) -> boolean
true
if a window was found and focused, false
otherwise; nil
if the search couldn't take placecandidateWindows
, Hammerspoon will query for the list of all visible windows every time this method is called; this can be slow, and some undesired "windows" could be included (see the notes for hs.window.allWindows()
); consider using the equivalent methods in hs.window.filter
insteadhs.window:frame() -> hs.geometry rect
hs.window:id() -> number or nil
hs.window:isFullScreen() -> bool or nil
hs.window:isMaximizable() -> bool or nil
hs.window:isMinimized() -> bool
hs.window:isStandard() -> bool
hs.window:isVisible() -> boolean
true
if the window is visible, otherwise false
hs.window:maximize([duration]) -> hs.window object
hs.window.animationDuration
hs.window
objecths.window:minimize() -> window
hs.window
objecths.window.animationDuration
hs.window:move(rect[, screen][, ensureInScreenBounds][, duration]) --> hs.window object
hs.geometry
point, or argument to construct one; will move the screen by this delta, keeping its size constant; screen
is ignoredhs.geometry
rect, or argument to construct one; will set the window frame to this rect, in absolute coordinates; screen
is ignoredhs.geometry
unit rect, or argument to construct one; will set the window frame to this rect relative to the desired screen; if screen
is nil, use the screen the window is currently onhs.screen
object or argument for hs.screen.find
; only valid if rect
is a unit recttrue
, use setFrameInScreenBounds()
to ensure the resulting window frame is fully contained within the window's screenhs.window.animationDuration
hs.window
objecths.window:moveOneScreenEast([noResize, ensureInScreenBounds][, duration]) -> hs.window object
true
, maintain the window's absolute sizetrue
, use setFrameInScreenBounds()
to ensure the resulting window frame is fully contained within the window's screenhs.window.animationDuration
hs.window
objecths.window:moveOneScreenNorth([noResize, ensureInScreenBounds][, duration]) -> hs.window object
true
, maintain the window's absolute size