Skip to content
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

Closed
Zebartin opened this issue Dec 18, 2023 · 5 comments
Closed

Comments

@Zebartin
Copy link

Zebartin commented Dec 18, 2023

  1. Autox.js 版本:656

  2. Autox.js 下载渠道:https://github.com/kkevsekk1/AutoX/releases

  3. Android 版本:Android 14

  4. Android 机型:三星 / 小米13Pro

  5. Android 系统类别:OneUI 16 / MIUI 14

  6. VSCODE Autox.js 扩展版本(可选,如果是连接电脑的问题需要填):

  7. 问题描述:

    更新到android 14之后,申请截屏权限时无法找到“立即开始”对应的控件。

    尝试用以下代码列出所有屏幕下半区域的控件,可以找到“取消”,但没有“立即开始”或其他clickable的控件,日志如下方所示
    boundsInside(0, device.height / 2, device.width, device.height).find().forEach(x=>log(x));

  8. 报错日志(可选):

  9. 屏幕截图(可选):

@aiselp
Copy link
Contributor

aiselp commented Dec 23, 2023

可能是安卓14新加入的限制,可尝试计算坐标点击,虽然不一定有效

@Zebartin
Copy link
Author

坐标点击是能生效的,只是不太灵活,想看看autox这边有什么办法

@zhyxxxxxx
Copy link

同样问题,小米12 更新hyperos 安卓14之后,出现立即开始点击失效

@fanlushuai
Copy link

fanlushuai commented Apr 22, 2024

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()

Copy link

此lssue由于长期未活动已被自动关闭,如问题任然存在,请重新打开lssue

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants