API Docs

Object representing a window. You should not instantiate these directly, but rather, use the methods in hs.window to create them for you.

Properties

application

HSApplication
The application that owns this window

pid

number
The process ID of the application that owns this window

id

number
The window's underlying ID. A value of 0 or -1 likely means no window ID could be determined.

isMinimized

boolean
Whether the window is minimized

isVisible

boolean
Whether the window is visible (not minimized or hidden)

isFocused

boolean
Whether the window is focused

isFullscreen

boolean
Whether the window is fullscreen

isStandard

boolean
Whether the window is standard (has a titlebar)

position

HSPoint
The window's position on screen {x: Int, y: Int}

size

HSSize
The window's size {w: Int, h: Int}

frame

HSRect
The window's frame {x: Int, y: Int, w: Int, h: Int}

screen

HSScreen
The screen that contains the largest portion of this window.

Methods

focus() -> boolean

Focus this window
focus() -> boolean
boolean
true if successful
const wins = hs.window.allWindows()
wins[0].focus()

minimize() -> boolean

Minimize this window
minimize() -> boolean
boolean
true if successful
const win = hs.window.focusedWindow()
win.minimize()

unminimize() -> boolean

Unminimize this window
unminimize() -> boolean
boolean
true if successful
const win = hs.window.allWindows()[0]
win.unminimize()

raise() -> boolean

Raise this window to the front
raise() -> boolean
boolean
true if successful
const win = hs.window.allWindows()[0]
win.raise()

toggleFullscreen() -> boolean

Toggle fullscreen mode
toggleFullscreen() -> boolean
boolean
true if successful
const win = hs.window.focusedWindow()
win.toggleFullscreen()

close() -> boolean

Close this window
close() -> boolean
boolean
true if successful
const win = hs.window.focusedWindow()
win.close()

centerOnScreen() -> None

Center the window on the screen
centerOnScreen() -> None
None
const win = hs.window.focusedWindow()
win.centerOnScreen()

axElement() -> HSAXElement

Get the underlying AXElement
axElement() -> HSAXElement
HSAXElement
The accessibility element for this window
const win = hs.window.focusedWindow()
const ax = win.axElement()