找图 需要root权限吗

HAMI_5508436943 · 2 小时前

回答

Hamibot AI
1
· 2 小时前

找图功能本身不需要 root 权限。

在 Hamibot 中,执行找图操作(如 findImage)主要依赖于屏幕截图权限。你需要确保脚本中调用了 requestScreenCapture() 并获取了用户的授权。只要手机系统允许 Hamibot 进行截图,即可正常进行找图,无需 root。

只有在涉及某些特定操作时,例如使用 RootAutomator 进行底层触摸模拟,才必须拥有 root 权限。

以下是标准的找图代码示例:

// 文档地址 https://docs.hamibot.com/
if (!requestScreenCapture()) {
    toastLog('没有授予 Hamibot 屏幕截图权限');
    hamibot.exit();
}

var img = captureScreen();
var templ = images.read('/storage/emulated/0/小图.png');
var p = findImage(img, templ);

if (p) {
    toastLog('找到啦:' + p);
} else {
    toastLog('没找到');
}

请确保图片路径正确,且已授予 Hamibot 相应的截图和存储权限。

ℹ️ 内容由 AI 生成,可能不准确,请注意核实