截图怎么跳过权限弹窗

已存档
3145525826_TNVF · 2 个月前

回答

神秘机师
250
· 2 个月前

可以用线程去点击,参考:

// 启用线程,点击截图确认按钮
threads.start(function () {
  const check = () => {
    // MIUI 系统
    let activity = currentActivity().toLowerCase();
    if (activity.indexOf('permission') !== -1) {
      if (
        id('com.android.systemui:id/dialog_title')
          .textContains('Hamibot')
          .exists()
      ) {
        // TODO 点击确认
        if (id('android:id/button1').findOnce().click()) {
          return; // 点击成功,不再检查
        }
      }
    }
    // TODO 检查其他系统
    // 未确认,继续检查
    setTimeout(function () {
      check();
    }, 500);
  };
  check();
});
if (!requestScreenCapture()) {
  hamibot.exit(); // 没获得授权,退出
}
threads.shutDownAll(); // 结束线程
sleep(1000); // 可选,短暂延迟,避免截图包含确认框
// 其他代码
0