#hs.uielement

A generalized framework for working with OSX UI elements


#Submodules


#API Overview

Functions - API calls offered directly by the extension

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


#API Documentation

#Functions

Signaturehs.uielement.focusedElement() -> element or nil
TypeFunction
DescriptionGets the currently focused UI element
Parameters
  • None
Returns
  • An hs.uielement object or nil if no object could be found
NotesNone
ExamplesNone
Sourceextensions/uielement/libuielement.m line 12

#Methods

Signaturehs.uielement:isApplication() -> bool
TypeMethod
DescriptionReturns whether the UI element represents an application.
Parameters
  • None
Returns
  • A boolean, true if the UI element is an application
NotesNone
ExamplesNone
Sourceextensions/uielement/uielement.lua line 14

Signaturehs.uielement:isWindow() -> bool
TypeMethod
DescriptionReturns whether the UI element represents a window.
Parameters
  • None
Returns
  • A boolean, true if the UI element is a window, otherwise false
NotesNone
ExamplesNone
Sourceextensions/uielement/libuielement.m line 29

| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | hs.uielement:newWatcher(handler[, userData]) -> hs.uielement.watcher or nil | | Type | Method | | Description | Creates a new watcher | | Parameters |

  • A function to be called when a watched event occurs. The function will be passed the following arguments: element: The element the event occurred on. Note this is not always the element being watched. event: The name of the event that occurred. watcher: The watcher object being created. userData: The userData you included, if any.
  • an optional userData object which will be included as the final argument to the callback function when it is called.
| | Returns |
  • An hs.uielement.watcher object, or nil if an error occurred
| | Notes | None | | Examples | None | | Source | extensions/uielement/libuielement.m line 86 |


Signaturehs.uielement:role() -> string
TypeMethod
DescriptionReturns the role of the element.
Parameters
  • None
Returns
  • A string containing the role of the UI element
NotesNone
ExamplesNone
Sourceextensions/uielement/libuielement.m line 47

Signaturehs.uielement:selectedText() -> string or nil
TypeMethod
DescriptionReturns the selected text in the element
Parameters
  • None
Returns
  • A string containing the selected text, or nil if none could be found
Notes
  • Many applications (e.g. Safari, Mail, Firefox) do not implement the necessary accessibility features for this to work in their web views
ExamplesNone
Sourceextensions/uielement/libuielement.m line 65