回答
文档地址 https://docs.hamibot.com/
以下是一个通用自动点赞脚本框架,请根据实际需求调整:
auto.waitFor();
if (!requestScreenCapture()) {
toastLog('需要截图权限');
hamibot.exit();
}
// 设置模板图片路径
var likeTemplate = images.read("/sdcard/like_icon.png");
var threshold = 0.9; // 相似度阈值
while(true) {
// 每秒截屏一次
var screen = captureScreen();
// 在屏幕中查找点赞图标
var pos = images.findImage(screen, likeTemplate, {
threshold: threshold,
// 可选区域搜索:[x1, y1, width, height]
// region: [0, 0, 1080, 1920]
});
if(pos) {
// 找到图标后点击
click(pos.x, pos.y);
toast("点赞成功");
}
sleep(1000); // 每秒检测一次
}
注意事项:
- 需将真实点赞图标截图保存为
/sdcard/like_icon.png
- 可调整 threshold 值匹配不同清晰度(0-1)
- 如目标应用有控件ID推荐改用控件模式:
var likeButton = id("like_button_id").findOne(); likeButton.click();
- 不同应用需修改对应选择器和坐标参数
权限提示:首次运行需手动授予"无障碍服务"和"屏幕截图"权限。
ℹ️ 本回答由 AI 生成,内容仅供参考