环境:auto.js 4.1.1
安卓手机:红米K20 pro
微信窗口中查找指定的字符串,如果当前页面没找到就上划再找,直到找到或达到限定的上滑次数
水平有限,请多指教。
查找控件函数借鉴了aidezhanxian
的文章 https://blog.csdn.net/aidezhanxian/article/details/123402729
var findCharacters = false;
var targetText = "晚上8:00";
j = 0
findString();
function findString() {
do {
let rooot2 = className("android.widget.TextView").find();
queryList(rooot2);
if (findCharacters) {
return;
};
j++;
log(j);
swipe(device.width / 2, device.height * 0.2, device.width / 2, device.height * 0.7, 500);
log((j > 10) || findCharacters);
}
while (!((j > 20) || findCharacters));
};
function queryList(json) {
for (var i = 0; i < json.length; i++) {
var sonList = json[i];
if (sonList.childCount() == 0) {
try {
log(sonList.text());
if (sonList.text() == targetText) {
findCharacters = true;
log("找到了")
return;
}
}
catch (err) { };
} else {
//console.log(json[i])
queryList(sonList);
}
}
};