- root
- desktop
- focused
- frompoint
- fromhandle
- find
- findby
- child
- children
- property
- name
- properties
- firstchild
- lastchild
- nextsibling
- previoussibling
- setvalue
- dodefaultaction
- toggle
- rangesetvalue
The uia
library provides access to the Windows Automation API.
local uia = libs.uia;
Tip: Inspect Objects is a useful utility (included in the Windows SDK).
Returns the root automation element.
root = uia.root();
Returns the desktop automation element.
desktop = uia.desktop();
Returns the current focused automation element.
focused = uia.focused();
Returns the automation element at the specified screen coordinates.
element = uia.frompoint(123, 456);
Returns the automation element for the specified window handle.
hwnd = win.find("some_class_name", nil);
element = uia.fromhandle(hwnd);
Finds the first element with the given name. Default scope is children.
-- Finds the first child of desktop named "Netflix".
desktop = uia.desktop();
netflix = uia.find(desktop, "Netflix");
Valid scopes are: ancestors
, children
, descendants
, element
, parent
, subtree
.
-- Finds the first element in the entire subtree of netflix named "PauseResume"
uia.find(netflix, "PauseResume", "subtree");
Warning: Avoid using subtree on large hierarchies as it can take a long time to complete.
Finds the first element with the given value for the given property name. Default scope is children.
desktop = uia.desktop();
foo = uia.findby(desktop, "ProcessId", "int", 3196);
Supported types are: string
, double
, float
, int
, bool
, long
.
Returns the child element at the given index (note 0-index).
desktop = uia.desktop();
first = uia.child(desktop, 0);
Returns an array of all child elements for the given parent.
desktop = uia.desktop();
children = uia.children(desktop);
Returns the value of the specified property name.
desktop = uia.desktop();
name = uia.property(name);
Returns the name of the given element.
desktop = uia.desktop();
name = uia.name(desktop);
Returns a table of properties for the given element.
desktop = uia.desktop();
props = uia.properties(desktop);
Returns the first child (or nil) of the specified element.
desktop = uia.desktop();
first = uia.firstchild(desktop);
Returns the last child (or nil) of the specified element.
desktop = uia.desktop();
last = uia.lastchild(desktop);
Returns the next sibling (or nil) of the specified element.
desktop = uia.desktop();
next = uia.nextsibling(desktop);
Returns the previous sibling (or nil) of the specified element.
desktop = uia.desktop();
previous = uia.previoussibling(desktop);
Sets the value of an element that implements the ValuePattern.
element = ...;
uia.setvalue(element, 50);
Perform the default action of an element that implements the LegacyAccessibilityPattern.
element = ...;
uia.dodefaultaction(element);
Toggles the state of an element that implements the TogglePattern.
element = ...;
uia.toggle(element);
Sets the range value of an element that implements the RangeValuePattern.
element = ...;
uia.setrangevalue(element, 50);