跳到主要内容

获取指定坐标的文本元素(mobile.elementsWithTextAtPosition)

函数

元素信息 = mobile.elementsWithTextAtPosition(屏幕横坐标,屏幕纵坐标)

参数

  • 屏幕横坐标 整数型

  • 屏幕纵坐标 整数型

返回值

  • 元素信息 文本型

说明

用户获取当前设备屏幕上 指定坐标的 文本元素

示例

local m = sys.mtime()
local positionInfo = mobile.elementsWithTextAtPosition(986, 2236) --获取指定坐标的文本元素
print(string.format("抓取耗时: %d 毫秒" ,sys.mtime() - m))
local drawArray = {}
if (type(positionInfo) == "table") then
local drawView = screenDraw.init(positionInfo.x , positionInfo.y, positionInfo.w, positionInfo.h , positionInfo.text and positionInfo.text or "") --绘制一个方框
drawView:show()
table.insert(drawArray, drawView) --将绘制方框 添加到 table中 防止被自动回收
end

for i =1 , 10 do
sys.toast(string.format("脚本还有 %d 秒退出" ,10 - i))
sys.msleep(1000)
end