From c0019cffa72b0b54e8aabfca6cd25400553ed57c Mon Sep 17 00:00:00 2001 From: Jamis Date: Mon, 28 Jul 2025 23:51:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=9F=E5=93=81=E5=8A=A0=E5=B7=A5=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=9A=E5=9B=BE=E5=83=8F=E8=AF=86=E5=88=AB=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6fallback=E5=88=B0OCR=E8=AF=86=E5=88=AB?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E6=94=AF=E6=8C=81=E8=BF=BD=E5=8A=A0=E6=AD=A3?= =?UTF-8?q?=E5=9C=A8=E8=A2=AB=E5=8A=A0=E5=B7=A5=E7=9A=84=E9=A3=9F=E6=9D=90?= =?UTF-8?q?=20(#1432)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repo/js/食材加工 识图/main.js | 45 ++++++++++++++++++++--------- repo/js/食材加工 识图/manifest.json | 4 +-- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/repo/js/食材加工 识图/main.js b/repo/js/食材加工 识图/main.js index 6dda06ca..8863a7d2 100644 --- a/repo/js/食材加工 识图/main.js +++ b/repo/js/食材加工 识图/main.js @@ -415,23 +415,42 @@ async function AutoPath() { await sleep(1000); // 等待1秒以确保点击生效 foundIngredient = true; - // 执行额外的点击操作(如果需要) - await performExtraClicks(processingKey); - - // 点击确认按钮 - click(1600, 1020); await sleep(2000); - - // 执行 PrepCount 操作 - const PrepCount = PrepCountArray.length > 0 ? PrepCountArray.shift() : defaultPrepCount; - if (PrepCount > 0) { - await performPrepCountActions(PrepCount); - } - break; // 找到食材后跳出循环 } } - if (!foundIngredient) { + // 图像识别未成功,可能是因为该食材正在被加工,通过OCR识别 + const ocrResult = captureGameRegion().findMulti(RecognitionObject.ocr(112, 118, 1161, 345)); + for (var i = 0; i < ocrResult.count; ++i) { + if (ocrResult[i].text.endsWith("分钟") || ocrResult[i].text.endsWith("秒")) { + // 选中该食材 + click(ocrResult[i].x, ocrResult[i].y); + await sleep(500); + // OCR食材名称 + const ocrResult2 = captureGameRegion().findMulti(RecognitionObject.ocr(1308, 122, 492, 52)); + const ingredientName = ocrResult2.count > 0 ? ocrResult2[0].text : null; + if (ingredientName === chineseDescription) { + log.info(`通过OCR识别找到食材: ${chineseDescription}`); + foundIngredient = true; + break; + } + } + } + } + + if (foundIngredient) { + // 执行额外的点击操作(如果需要) + await performExtraClicks(processingKey); + + // 点击确认按钮 + click(1600, 1020); await sleep(2000); + + // 执行 PrepCount 操作 + const PrepCount = PrepCountArray.length > 0 ? PrepCountArray.shift() : defaultPrepCount; + if (PrepCount > 0) { + await performPrepCountActions(PrepCount); + } + } else { log.error(`未能识别到食材: ${chineseDescription}`); } } diff --git a/repo/js/食材加工 识图/manifest.json b/repo/js/食材加工 识图/manifest.json index 29cea9b4..773d7b57 100644 --- a/repo/js/食材加工 识图/manifest.json +++ b/repo/js/食材加工 识图/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 1, "name": "选择加工食材", - "version": "2.1", + "version": "2.2", "description": "食材加工 识图 复选框。", "authors": [ { @@ -15,4 +15,4 @@ ], "settings_ui": "settings.json", "main": "main.js" -} \ No newline at end of file +}