修复recognizeTextAndClick函数偶发识别异常的问题 (#1036)

由于点击的坐标是根据OCR坐标计算出来的,如果click的参数x和y一个是整数,一个是浮点,会报错`Invalid argument specified for parameter 'arg1'`

需要取消catch才能看到报错,不然会被catch而当做找不到文字掩盖
This commit is contained in:
Patrick-Ze
2025-06-09 15:13:02 +08:00
committed by GitHub
parent 76c6ad7793
commit 5445b4285c
7 changed files with 10 additions and 9 deletions

View File

@@ -93,6 +93,7 @@
- **双风阵容**:如早柚+枫原万叶/砂糖(提高移速)
- **迪希雅**:白天时段提供移速加成
- **罗莎莉亚**: 夜晚时段提供移速加成
## 六、选择建议

View File

@@ -46,8 +46,8 @@ async function recognizeTextAndClick(targetText, ocrRegion, timeout = 5000) {
if (correctedText.includes(targetText)) {
// 如果找到目标文本,计算并点击文字的中心坐标
let centerX = res.x + res.width / 2;
let centerY = res.y + res.height / 2;
let centerX = Math.round(res.x + res.width / 2);
let centerY = Math.round(res.y + res.height / 2);
await click(centerX, centerY);
await sleep(500); // 确保点击后有足够的时间等待
return { success: true, x: centerX, y: centerY };

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "读取当前摩拉记录并发送通知",
"version": "1.1",
"version": "1.1.1",
"description": "至少0.44.3版本。OCR识别摩拉数值输出到本地",
"authors": [
{

View File

@@ -46,8 +46,8 @@ async function recognizeTextAndClick(targetText, ocrRegion, timeout = 5000) {
if (correctedText.includes(targetText)) {
// 如果找到目标文本,计算并点击文字的中心坐标
let centerX = res.x + res.width / 2;
let centerY = res.y + res.height / 2;
let centerX = Math.round(res.x + res.width / 2);
let centerY = Math.round(res.y + res.height / 2);
log.info(`识别到目标文本: ${correctedText},点击坐标: x=${centerX}, y=${centerY}`);
await click(centerX, centerY);
await sleep(500); // 确保点击后有足够的时间等待

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "PathMoraLogger路径摩拉记录",
"version": "1.0",
"version": "1.0.1",
"description": "用于测试路线的摩拉效率要求bgi版本不低于44.8",
"authors": [
{

View File

@@ -79,8 +79,8 @@ async function recognizeTextAndClick(targetText, ocrRegion, timeout = 5000) {
if (correctedText.includes(targetText)) {
// 如果找到目标文本,计算并点击文字的中心坐标
let centerX = res.x + res.width / 2;
let centerY = res.y + res.height / 2;
let centerX = Math.round(res.x + res.width / 2);
let centerY = Math.round(res.y + res.height / 2);
log.info(`通过 OCR 识别找到文字: ${targetText}`);
log.info(`中心坐标: x=${centerX}, y=${centerY}`);
await click(centerX, centerY); // 执行点击操作

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 1,
"name": "选择画质",
"version": "2.1",
"version": "2.1.1",
"description": "0.6或1.0精度切换增加识图定位增加画质、动态模糊、Bloom选项",
"authors": [
{