-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
安卓14申请截屏权限时无法找到“立即开始”对应的控件 #772
Labels
Comments
可能是安卓14新加入的限制,可尝试计算坐标点击,虽然不一定有效 |
坐标点击是能生效的,只是不太灵活,想看看autox这边有什么办法 |
同样问题,小米12 更新hyperos 安卓14之后,出现立即开始点击失效 |
let hasGetCapturePremission = false
function autoPermisionScreenCapture() {
if (hasGetCapturePremission) {
log("当前有截图权限");
return;
}
console.log("自动申请截图权限");
let Thread = threads.start(function () {
if (auto.service == null) {
toast("无障碍未开启")
return
}
let ele = textMatches(/(.*录屏或投屏.*|.*录制或投射.*|允许|立即开始|统一)/).findOne(10 * 1000)
if (ele == null) {
toast("未能发现截图权限弹窗")
return
}
log("已经弹出权限确认界面")
let eles = textMatches(/(.*录屏或投屏.*|.*录制或投射.*|允许|立即开始|统一)/).find()
if (eles.empty()) {
toast("未能发现截图权限弹窗")
return
}
let notMiui14Style = false
for (let e of eles) {
let text = e.text()
if (text.indexOf('立即开始') > 0 || text.indexOf('允许') > 0 || text.indexOf('统一')) {
notMiui14Style = true
break
}
}
if (notMiui14Style) {
log("可以找到立即开始")
let allowEle = textMatches(/(允许|立即开始|统一)/).findOne(10 * 1000);
if (allowEle) {
sleep(1500)
if (allowEle.clickable()) {
log("点击 元素")
let ok = allowEle.click();
return ok;
} else {
let b = allowEle.bounds()
log("按压 坐标")
return press(b.centerX(), b.centerY(), 1)
}
}
} else {
// 在miui 14中,立即开始,不可找到。使用推测的方式来处理
log("推测 立即开始 坐标")
let cancel = text("取消").findOne(10 * 10000)
if (cancel) {
log("取消 按钮 存在")
let x = device.width - cancel.bounds().centerX()
let y = cancel.bounds().centerY()
log("点击 推测坐标 %s %s", x, y)
sleep(1500)
press(x, y, 1)
} else {
log("取消按钮不存在,推测失败")
}
}
});
log("申请权限");
//在一个会话中,调用两次申请截图权限。就会卡死。
if (!requestScreenCapture(false)) {
toast("请求截图权限失败");
return false;
} else {
Thread.interrupt();
log("已获得截图权限");
hasGetCapturePremission = true;
return true;
}
}
autoPermisionScreenCapture() |
此lssue由于长期未活动已被自动关闭,如问题任然存在,请重新打开lssue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Autox.js 版本:656
Autox.js 下载渠道:https://github.com/kkevsekk1/AutoX/releases
Android 版本:Android 14
Android 机型:三星 / 小米13Pro
Android 系统类别:OneUI 16 / MIUI 14
VSCODE Autox.js 扩展版本(可选,如果是连接电脑的问题需要填):
问题描述:
更新到android 14之后,申请截屏权限时无法找到“立即开始”对应的控件。
尝试用以下代码列出所有屏幕下半区域的控件,可以找到“取消”,但没有“立即开始”或其他clickable的控件,日志如下方所示
boundsInside(0, device.height / 2, device.width, device.height).find().forEach(x=>log(x));
报错日志(可选):
屏幕截图(可选):
The text was updated successfully, but these errors were encountered: