HSAXElement
TypeObject representing an Accessibility element. You should not instantiate this directly, but rather, use the hs.ax methods to create these as required.
Properties
Methods
children() -> HSAXElement[]
The element's children
Declaration
children() -> HSAXElement[]
Returns
HSAXElement[]
An array of HSAXElement objects
Example
const el = hs.ax.focusedElement()
console.log(el.children().length)
childAtIndex(index) -> HSAXElement
Get a specific child by index
Declaration
childAtIndex(index) -> HSAXElement
Parameters
| Name | Type | Description |
|---|---|---|
| index | number | The index to fetch |
Returns
HSAXElement
An HSAXElement object, if a child exists at the given index
Example
const el = hs.ax.focusedElement()
const child = el.childAtIndex(0)
attributeNames() -> string[]
Get all available attribute names
Declaration
attributeNames() -> string[]
Returns
string[]
An array of attribute names
Example
const el = hs.ax.focusedElement()
console.log(el.attributeNames())
attributeValue(attribute) -> any
Get the value of a specific attribute
Declaration
attributeValue(attribute) -> any
Parameters
| Name | Type | Description |
|---|---|---|
| attribute | string | The attribute name to fetch the value for |
Returns
any
The requested value, or nil if none was found
Example
const el = hs.ax.focusedElement()
console.log(el.attributeValue("AXTitle"))
setAttributeValue(attribute, value) -> boolean
Set the value of a specific attribute
Declaration
setAttributeValue(attribute, value) -> boolean
Parameters
| Name | Type | Description |
|---|---|---|
| attribute | string | The attribute name to set |
| value | any | The value to set |
Returns
boolean
True if the operation succeeded, otherwise False
Example
const el = hs.ax.focusedElement()
el.setAttributeValue("AXValue", "Hello")
isAttributeSettable(attribute) -> boolean
Check if an attribute is settable
Declaration
isAttributeSettable(attribute) -> boolean
Parameters
| Name | Type | Description |
|---|---|---|
| attribute | string | An attribute name |
Returns
boolean
True if the attribute is settable, otherwise False
Example
const el = hs.ax.focusedElement()
console.log(el.isAttributeSettable("AXValue"))
actionNames() -> string[]
Get all available action names
Declaration
actionNames() -> string[]
Returns
string[]
An array of available action names
Example
const el = hs.ax.focusedElement()
console.log(el.actionNames())
performAction(action) -> boolean
Perform a specific action
Declaration
performAction(action) -> boolean
Parameters
| Name | Type | Description |
|---|---|---|
| action | string | The action to perform |
Returns
boolean
True if the action succeeded, otherwise False
Example
const el = hs.ax.focusedElement()
el.performAction("AXPress")