Get UI Element at Position (ui_element.text_element_at_position)
This function is available in versions after 20260507
Declaration
element, err = ui_element.text_element_at_position(x, y [, pid_or_options ])
Parameters
- x, y Integer. Screen coordinate in physical pixels.
- pid_or_options Optional, integer or table. Integer means target app process identifier; table options are described in Common options.
Returns
- element
Table. UI element hit at the coordinate.
nilon failure. - err String. Failure reason.
Description
Use this API when you already know a point and want to read the UI element there, such as after image recognition or OCR. This is not a coordinate click API. For fixed-coordinate clicks, use touch.tap. It may fail when the point is blank or the target screen does not expose a readable element there.
Example
local ui_element = require("ui_element")
local item, err = ui_element.text_element_at_position(300, 500, {
include_hit_state = true,
max_level = 1,
})
if item then
nLog(item.text or item.value or "")
else
sys.toast(err)
end