#cp.ui.Window

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

Signaturecp.ui.Window.findSectionUI(windowUI, sectionID) -> hs.axuielement
TypeFunction
DescriptionFinds the axuielement for the specified sectionID, if present in the provided axuielement windowUI.
Parameters
  • windowUI - The AXWindow axuielement to search in.
  • sectionID - The string value for the SectionUniqueID.
Returns
  • The matching axuielement, or nil.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 381

Signaturecp.ui.Window.matches(element) -> boolean
TypeFunction
DescriptionChecks if the provided element is a valid window.
Parameters
  • element - An element to check
Returns
  • A boolean
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 24

#Constructors

Signaturecp.ui.Window(cpApp, uiProp) -> Window
TypeConstructor
DescriptionCreates a new Window
Parameters
  • cpApp - a cp.app for the application the Window belongs to.
  • uiProp - a cp.prop that returns the hs.axuielement for the window.
Returns
  • A new Window instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 48

#Fields

Signaturecp.ui.Window.alert <cp.ui.Alert>
TypeField
DescriptionProvides access to any 'Alert' windows on the Window.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 374

Signaturecp.ui.Window.exists <cp.prop: boolean; read-only>
TypeField
DescriptionReturns true if the window exists. It may not be visible.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 174

Signaturecp.ui.Window.focused <cp.prop: boolean>
TypeField
DescriptionIs true if the window has mouse/keyboard focused.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 132

Signaturecp.ui.Window.frame <cp.prop: hs.geometry rect>
TypeField
DescriptionThe hs.geometry rect value describing the window's position.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 206

Signaturecp.ui.Window.hsWindow <cp.prop: hs.window; read-only>
TypeField
DescriptionThe hs.window instance for the window, or nil if it can't be found.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 78

Signaturecp.ui.Window.id <cp.prop: string; read-only>
TypeField
DescriptionThe window title, or nil if the window is not currently visible.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 105

Signaturecp.ui.Window.isFullScreen <cp.prop: boolean>
TypeField
DescriptionReturns true if the window is full-screen.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 273

Signaturecp.ui.Window.isShowing <cp.prop: boolean; read-only; live?>
TypeField
DescriptionIndicates if the Window is currently showing on screen.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 71

Signaturecp.ui.Window.minimized <cp.prop: boolean>
TypeField
DescriptionReturns true if the window exists and is minimised.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 181

Signaturecp.ui.Window.position <cp.prop: table>
TypeField
DescriptionGets or sets the window position
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 251

Signaturecp.ui.Window.size <cp.prop: table>
TypeField
DescriptionGets or sets the window size
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 229

Signaturecp.ui.Window.UI <cp.prop: hs.axuielement: read-only; live?>
TypeField
DescriptionThe UI axuielement for the Window.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 63

Signaturecp.ui.Window.visible <cp.prop: boolean; read-only>
TypeField
DescriptionReturns true if the window is visible on a screen.
NotesNone
Sourcesrc/extensions/cp/ui/Window.lua line 117

#Methods

Signaturecp.ui.Window:close() -> boolean
TypeMethod
DescriptionAttempts to close the window.
Parameters
  • None
Returns
  • true if the window was successfully closed.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 299

Signaturecp.ui.Window:doClose() -> cp.rx.go.Statement <boolean>
TypeMethod
DescriptionReturns a Statement that will attempt to close the window, if it is visible.
Parameters
  • None
Returns
  • The Statement to execute, resolving to true if the window is closed successfully, or false if not.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 313

Signaturecp.ui.Window:doFocus() -> cp.rx.go.Statement
TypeMethod
DescriptionReturns a Statement will attempt to focus on the window, if it is visible.
Parameters
  • None
Returns
  • The Statement to execute, which resolves to true if the window was successfully focused, or false if not.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 345

Signaturecp.ui.Window:findSectionUI(sectionID) -> hs.axuielement
TypeMethod
DescriptionLooks for th section with the specified SectionUniqueID value and returns the matching axuielement value.
Parameters
  • sectionID - The string for the section ID.
Returns
  • The matching axuielement, or nil.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 404

Signaturecp.ui.Window:focus() -> boolean
TypeMethod
DescriptionAttempts to focus the window.
Parameters
  • None
Returns
  • true if the window was successfully focused.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 331

Signaturecp.ui.Window:notifier() -> cp.ui.notifier
TypeMethod
DescriptionReturns a notifier that is tracking the application UI element. It has already been started.
Parameters
  • None
Returns
  • The notifier.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 417

Signaturecp.ui.Window:snapshot([path]) -> hs.image | nil
TypeMethod
DescriptionTakes a snapshot of the UI in its current state as a PNG and returns it. If the path is provided, the image will be saved at the specified location.
Parameters
  • path - (optional) The path to save the file. Should include the extension (should be .png).
Returns
  • The hs.image that was created, or nil if the UI is not available.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/Window.lua line 430