Window

Last updated 6 months ago

A Window UI element.

API Overview

  • Functions - API calls offered directly by the extension

  • Constructors - API calls which return an object, typically one that offers API methods

  • Fields - Variables which can only be accessed from an object returned by a constructor

  • Methods - API calls which can only be made on an object returned by a constructor

API Documentation

Functions

matches

Signature

cp.ui.Window.matches(element) -> boolean

Type

Function

Description

Checks if the provided element is a valid window.

Constructors

new

Signature

cp.ui.Window.new(cpApp, uiProp) -> Window

Type

Constructor

Description

Creates a new Window

Parameters

cpApp - a cp.app for the application the Window belongs to. * uiProp - a cp.prop that returns the hs._asm.axuielement for the window.

Returns

A new Window instance.

Fields

exists

Signature

cp.ui.Window.exists <cp.prop: boolean; read-only>

Type

Field

Description

Returns true if the window exists. It may not be visible.

focused

Signature

cp.ui.Window.focused <cp.prop: boolean>

Type

Field

Description

Is true if the window has mouse/keyboard focused.

frame

Signature

cp.ui.Window.frame <cp.prop: hs.geometry rect>

Type

Field

Description

The hs.geometry rect value describing the window's position.

Signature

cp.ui.Window.fullScreen <cp.prop: boolean>

Type

Field

Description

Returns true if the window is full-screen.

hsWindow

Signature

cp.ui.Window.hsWindow <cp.prop: hs.window; read-only>

Type

Field

Description

The hs.window instance for the window, or nil if it can't be found.

id

Signature

cp.ui.Window.id <cp.prop: number; read-only>

Type

Field

Description

The unique ID for the window.

minimized

Signature

cp.ui.Window.minimized <cp.prop: boolean>

Type

Field

Description

Returns true if the window exists and is minimised.

UI

Signature

cp.ui.Window.UI <cp.prop: hs._asm.axuielement: read-only; live?>

Type

Field

Description

The UI axuielement for the Window.

visible

Signature

cp.ui.Window.visible <cp.prop: boolean; read-only>

Type

Field

Description

Returns true if the window is visible on a screen.

Methods

close

Signature

cp.ui.Window.close() -> boolean

Type

Method

Description

Attempts to close the window.

Parameters

None

Returns

true if the window was successfully closed.

focus

Signature

cp.ui.Window.focus() -> boolean

Type

Method

Description

Attempts to focus the window.

Parameters

None

Returns

true if the window was successfully focused.

notifier

Signature

cp.ui.Window:notifier() -> cp.ui.notifier

Type

Method

Description

Returns a notifier that is tracking the application UI element. It has already been started.

Parameters

None

Returns

The notifier.

snapshot

Signature

`cp.ui.Window:snapshot([path]) -> hs.image

nil` </span>

Type

Method

Description

Takes a snapshot of the UI in its current state as a PNG and returns it.

Parameters

path - (optional) The path to save the file. Should include the extension (should be .png).