//检查获取屏幕信息权限
if (!requestScreenCapture()) {
toastLog('没有授予 Hamibot 屏幕截图权限');
hamibot.exit();
}
toastLog('加载核心配置文件中');
const steps = {
sleep (8000)
toastLog('程序就绪');
//打开部落冲突
step1: () => {
launch('com.tencent.tmgp.supercell.clashofclans');
toastLog('部落冲突已启动');
},
sleep(6000)
step2: () => {
//OCR判断识别
var wx = images.read('/storage/emulated/0/tiaoshi/配置图片文件/小x.png');
//截图并找图
var p = findImage(captureScreen(), wx, {
region: [0, 50],
threshold: 0.6,
});
},
if (p) {
toastLog('找到图标啦:' + p);
} else {
toastLog('没有找到图标');
function jumpToStep(stepKey) {
const stepFunction = steps[stepKey];
if (stepFunction) {
stepFunction(); // 执行对应的步骤函数
} else {
console.error("步骤不存在:", stepKey);
}
}
jumpToStep('step2');
}
hamibot.exit();
};
运行时会报错,修复一下
回答
// 文档地址 https://docs.hamibot.com/
// 检查获取屏幕信息权限
if (!requestScreenCapture()) {
toastLog('没有授予 Hamibot 屏幕截图权限');
hamibot.exit();
}
toastLog('加载核心配置文件中');
const steps = {
sleep(8000);
toastLog('程序就绪');
// 打开部落冲突
step1: function() {
launch('com.tencent.tmgp.supercell.clashofclans');
toastLog('部落冲突已启动');
},
sleep(6000);
step2: function() {
// OCR判断识别
var wx = images.read('/storage/emulated/0/tiaoshi/配置图片文件/小x.png');
// 截图并找图
var p = findImage(captureScreen(), wx, {
region: [0, 50],
threshold: 0.6,
});
if (p) {
toastLog('找到图标啦:' + p);
} else {
toastLog('没有找到图标');
function jumpToStep(stepKey) {
const stepFunction = steps[stepKey];
if (stepFunction) {
stepFunction(); // 执行对应的步骤函数
} else {
console.error("步骤不存在:", stepKey);
}
}
jumpToStep('step2');
}
}
};
// 执行 step1
steps.step1();
// 执行 step2
steps.step2();
hamibot.exit();