findMiniProgram() {
try {
const maxRetry = 10;
let retry = 0;
let miniArr = null;
let machineArr = null;
while (retry < maxRetry) {
auto.setWindowFilter(function (window) {
return window.title == '微信';
});
miniArr = className('android.widget.TextView').id('bit').text('小程序').find();
if (miniArr && miniArr.length > 0) {
let target = miniArr[miniArr.length - 1];
return {
x: target.bounds().centerX(),
y: target.bounds().centerY()
};
}
auto.setWindowFilter(function (window) {
return window.title == '收藏';
});
machineArr = className('android.widget.TextView').id('dwp').depth(16).text('泡泡抽盒机').find();
if (machineArr && machineArr.length > 0) {
let target = machineArr[0];
return {
x: target.bounds().centerX(),
y: target.bounds().centerY()
};
}
retry++;
sleep(300);
}
return null;
} catch (e) {
console.error("查找小程序异常:", e);
return null;
}
}这段代码是否是分屏指定查找对应屏幕?
回答
不是,这段代码并不是分屏指定查找对应屏幕。它通过设置窗口过滤器(auto.setWindowFilter)来限定查找的窗口标题为“微信”或“收藏”,从而在特定的窗口中查找对应的控件。但是,这段代码并没有明确地处理分屏模式或者指定查找某个具体的屏幕区域。
ℹ️ 本回答由 AI 生成,内容仅供参考