docs » hs.uielement.watcher

Watch for events on certain UI elements (including windows and applications)

You can watch the following events:

Application-level events

See hs.application.watcher for more events you can watch.

Focus change events

These events are watched on the application level, but send the relevant child element to the handler.

Window-level events

Element-level events

These work on all UI elements, including windows.

API Overview

API Documentation

Methods

element
Signature hs.uielement.watcher:element() -> object
Type Method
Description

Returns the element the watcher is watching.

Parameters
  • None
Returns
  • The element the watcher is watching.
Source extensions/uielement/libuielement_watcher.m line 57
pid
Signature hs.uielement.watcher:pid() -> number
Type Method
Description

Returns the PID of the element being watched

Parameters
  • None
Returns
  • The PID of the element being watched
Source extensions/uielement/libuielement_watcher.m line 40
start
Signature hs.uielement.watcher:start(events) -> hs.uielement.watcher
Type Method
Description

Tells the watcher to start watching for the given list of events.

Parameters
  • An array of events to be watched for.
Returns
  • hs.uielement.watcher
Notes
  • See hs.uielement.watcher for a list of events. You may also specify arbitrary event names as strings.
  • Does nothing if the watcher has already been started. To start with different events, stop it first.
Source extensions/uielement/uielement.lua line 114
stop
Signature hs.uielement.watcher:stop() -> hs.uielement.watcher
Type Method
Description

Tells the watcher to stop listening for events.

Parameters
  • None
Returns
  • hs.uielement.watcher
Notes
  • This is automatically called if the element is destroyed.
Source extensions/uielement/uielement.lua line 148