1、获取界面xml(注:不是所有的界面都可以获取的xml)
Import "shanhai.lua"
Dim _xml=shanhai.getuixml()
TracePrint _xml
2、xml内容简单分析
右键复制xml,然后粘贴到文本里面


把这一段代码复制到文本以后,用搜索功能ctrl+f,查找要找的东西。
3、提取xml的文字
Import "shanhai.lua"
Dim _xml=shanhai.getuixml()
TracePrint _xml
dim content=shanhai.RegexFind(_xml,"text=""([^""]+)")
For Each k In content
TracePrint k
Next


4、根据文字点击(比较常用)
Import "shanhai.lua"
Dim _xml=shanhai.getuixml()
TracePrint _xml
Call click("设置")
Function click(n)
Dim xy=shanhai.regexfind(shanhai.findxmlkey(_xml,"text",n,"bounds"),"%d+")
If Len(xy(0)) = 0 Then
xy=shanhai.regexfind(shanhai.findxmlkey(_xml,"content-desc".n,"bounds"),"%d+")
End If
TracePrint xy(0),xy(1)
// Tap xy(0),xy(1)
End Function

5、点击包含指定文字的节点
比如 一段文字是“100人在看”,我们希望点击只要文字中含有“人在看”这几个字的节点。
Import "shanhai.lua"
Dim _xml=shanhai.getuixml()
TracePrint _xml
dim content=shanhai.RegexFind(_xml,"text=""([^""]+)")
For Each k In content
If InStr(1, k, "系统")>0 Then
click(k)
End If
Next
Function click(n)
Dim xy=shanhai.regexfind(shanhai.findxmlkey(_xml,"text",n,"bounds"),"%d+")
If Len(xy(0)) = 0 Then
xy=shanhai.regexfind(shanhai.findxmlkey(_xml,"content-desc".n,"bounds"),"%d+")
End If
TracePrint xy(0),xy(1)
// Tap xy(0),xy(1)
End Function

本期教程就这些。
以上便是小编为大家带来的手机怎么执行xml文件,希望对大家有所帮助,更多内容请继续关注蓝莓安卓网。