From 5445b4285c71ae5ad4db2f35e7535542094196a2 Mon Sep 17 00:00:00 2001 From: Patrick-Ze <19711799+Patrick-Ze@users.noreply.github.com> Date: Mon, 9 Jun 2025 15:13:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`recognizeTextAndClick`?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=81=B6=E5=8F=91=E8=AF=86=E5=88=AB=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98=20(#1036)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于点击的坐标是根据OCR坐标计算出来的,如果click的参数x和y一个是整数,一个是浮点,会报错`Invalid argument specified for parameter 'arg1'` 需要取消catch才能看到报错,不然会被catch而当做找不到文字掩盖 --- repo/js/AutoArtifactsPro/README.md | 1 + repo/js/OCR读取当前摩拉记录并发送通知/main.js | 4 ++-- repo/js/OCR读取当前摩拉记录并发送通知/manifest.json | 2 +- repo/js/PathMoraLogger路径摩拉记录/main.js | 4 ++-- repo/js/PathMoraLogger路径摩拉记录/manifest.json | 2 +- repo/js/切换画质/main.js | 4 ++-- repo/js/切换画质/manifest.json | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/repo/js/AutoArtifactsPro/README.md b/repo/js/AutoArtifactsPro/README.md index 329c1143..067c3dfa 100644 --- a/repo/js/AutoArtifactsPro/README.md +++ b/repo/js/AutoArtifactsPro/README.md @@ -93,6 +93,7 @@ - **双风阵容**:如早柚+枫原万叶/砂糖(提高移速) - **迪希雅**:白天时段提供移速加成 +- **罗莎莉亚**: 夜晚时段提供移速加成 ## 六、选择建议 diff --git a/repo/js/OCR读取当前摩拉记录并发送通知/main.js b/repo/js/OCR读取当前摩拉记录并发送通知/main.js index 7cece6d2..9d29cc01 100644 --- a/repo/js/OCR读取当前摩拉记录并发送通知/main.js +++ b/repo/js/OCR读取当前摩拉记录并发送通知/main.js @@ -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 }; diff --git a/repo/js/OCR读取当前摩拉记录并发送通知/manifest.json b/repo/js/OCR读取当前摩拉记录并发送通知/manifest.json index df5881e4..245790b9 100644 --- a/repo/js/OCR读取当前摩拉记录并发送通知/manifest.json +++ b/repo/js/OCR读取当前摩拉记录并发送通知/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "读取当前摩拉记录并发送通知", - "version": "1.1", + "version": "1.1.1", "description": "至少0.44.3版本。OCR识别摩拉数值输出到本地", "authors": [ { diff --git a/repo/js/PathMoraLogger路径摩拉记录/main.js b/repo/js/PathMoraLogger路径摩拉记录/main.js index 8f7363b8..51b583d8 100644 --- a/repo/js/PathMoraLogger路径摩拉记录/main.js +++ b/repo/js/PathMoraLogger路径摩拉记录/main.js @@ -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); // 确保点击后有足够的时间等待 diff --git a/repo/js/PathMoraLogger路径摩拉记录/manifest.json b/repo/js/PathMoraLogger路径摩拉记录/manifest.json index d915a5ce..a55445f5 100644 --- a/repo/js/PathMoraLogger路径摩拉记录/manifest.json +++ b/repo/js/PathMoraLogger路径摩拉记录/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "PathMoraLogger路径摩拉记录", - "version": "1.0", + "version": "1.0.1", "description": "用于测试路线的摩拉效率,要求bgi版本不低于44.8", "authors": [ { diff --git a/repo/js/切换画质/main.js b/repo/js/切换画质/main.js index 697234e2..daa14d04 100644 --- a/repo/js/切换画质/main.js +++ b/repo/js/切换画质/main.js @@ -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); // 执行点击操作 diff --git a/repo/js/切换画质/manifest.json b/repo/js/切换画质/manifest.json index 78718516..b0a6cc8a 100644 --- a/repo/js/切换画质/manifest.json +++ b/repo/js/切换画质/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "选择画质", - "version": "2.1", + "version": "2.1.1", "description": "0.6或1.0精度切换,增加识图定位,增加画质、动态模糊、Bloom选项,", "authors": [ {