HSWindow
TypeObject representing a window. You should not instantiate these directly, but rather, use the methods in hs.window to create them for you. Note that this type uses private macOS APIs
Properties
id
number
The window's underlying ID.
A value of 0 or -1 likely means no window ID could be determined.
Methods
focus() -> boolean
Focus this window
Declaration
focus() -> boolean
Returns
boolean
true if successful
Example
const wins = hs.window.allWindows()
wins[0].focus()
minimize() -> boolean
Minimize this window
Declaration
minimize() -> boolean
Returns
boolean
true if successful
Example
const win = hs.window.focusedWindow()
win.minimize()
unminimize() -> boolean
Unminimize this window
Declaration
unminimize() -> boolean
Returns
boolean
true if successful
Example
const win = hs.window.allWindows()[0]
win.unminimize()
raise() -> boolean
Raise this window to the front
Declaration
raise() -> boolean
Returns
boolean
true if successful
Example
const win = hs.window.allWindows()[0]
win.raise()
toggleFullscreen() -> boolean
Toggle fullscreen mode
Declaration
toggleFullscreen() -> boolean
Returns
boolean
true if successful
Example
const win = hs.window.focusedWindow()
win.toggleFullscreen()
close() -> boolean
Close this window
Declaration
close() -> boolean
Returns
boolean
true if successful
Example
const win = hs.window.focusedWindow()
win.close()
centerOnScreen() -> None
Center the window on the screen
Declaration
centerOnScreen() -> None
Returns
None
Example
const win = hs.window.focusedWindow()
win.centerOnScreen()
axElement() -> HSAXElement
Get the underlying AXElement
Declaration
axElement() -> HSAXElement
Returns
HSAXElement
The accessibility element for this window
Example
const win = hs.window.focusedWindow()
const ax = win.axElement()