diff --git a/repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/Picture/image1.png b/repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/Picture/image1.png new file mode 100644 index 000000000..85ecefe45 Binary files /dev/null and b/repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/Picture/image1.png differ diff --git a/repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/icon/Comfirm.png b/repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/icon/Comfirm.png new file mode 100644 index 000000000..201445d06 Binary files /dev/null and b/repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/icon/Comfirm.png differ diff --git a/repo/js/分解圣遗物 带背包过期弹窗自动点击/main.js b/repo/js/分解圣遗物 带背包过期弹窗自动点击/main.js new file mode 100644 index 000000000..156eed1ea --- /dev/null +++ b/repo/js/分解圣遗物 带背包过期弹窗自动点击/main.js @@ -0,0 +1,96 @@ +// 自定义 basename 函数 +function basename(filePath) { + const lastSlashIndex = filePath.lastIndexOf('\\'); // 或者使用 '/',取决于你的路径分隔符 + return filePath.substring(lastSlashIndex + 1); +} + +(async function () { + setGameMetrics(1920, 1080, 1); // 设置游戏分辨率 + await genshin.returnMainUi(); + keyPress("B"); await sleep(1000); + + // 定义图标文件夹路径 + const iconDir = "assets/icon"; + const pictureDir = "assets/Picture"; + + const iconFilePaths = file.ReadPathSync(iconDir); + const pictureFilePaths = file.ReadPathSync(pictureDir); + + const iconRecognitionObjects = []; + for (const filePath of iconFilePaths) { + const mat = file.readImageMatSync(filePath); + if (mat.empty()) { + log.error(`加载图标失败:${filePath}`); + continue; + } + const recognitionObject = RecognitionObject.TemplateMatch(mat, 0, 0, 1920, 1080); + iconRecognitionObjects.push({ name: basename(filePath), ro: recognitionObject }); + } + + const pictureRegions = []; + for (const filePath of pictureFilePaths) { + const mat = file.readImageMatSync(filePath); + if (mat.empty()) { + log.error(`加载图库失败:${filePath}`); + continue; + } + pictureRegions.push({ name: basename(filePath), region: new ImageRegion(mat, 0, 0) }); + } + + const foundRegions = []; + + for (const picture of pictureRegions) { + for (const icon of iconRecognitionObjects) { + // 在图库中查找图标信息 + const foundRegion = picture.region.find(icon.ro); + if (foundRegion.isExist()) { + foundRegions.push({ + pictureName: picture.name, + iconName: icon.name, + region: foundRegion + }); + } + } + } + + for (const foundRegion of foundRegions) { + + const ra = captureGameRegion(); + const tolerance = 1; // 容错区间 + const iconMat = file.ReadImageMatSync(`assets/icon/${foundRegion.iconName}`); + const recognitionObject = RecognitionObject.TemplateMatch(iconMat, foundRegion.region.x-tolerance, foundRegion.region.y-tolerance, foundRegion.region.width+2*tolerance, foundRegion.region.height+2*tolerance); + recognitionObject.threshold = 0.85; // 设置识别阈值为 0.9 + const result = ra.find(recognitionObject); + if (result.isExist() && result.x > 0 && result.y > 0) { + // 获取图标的中心坐标并取整 + const x = Math.round(foundRegion.region.x + foundRegion.region.width / 2); + const y = Math.round(foundRegion.region.y + foundRegion.region.height / 2); + + await click(x, y); + log.info(`点击 ${foundRegion.iconName}成功,位置: (${x}, ${y})`); + await sleep(500); // 等待一段时间 + } else { + // 如果未找到图标,打印警告信息 + log.info(`未发现背包弹窗:${foundRegion.iconName}`); + } + ra.dispose(); + } + + const coords = [ + [670, 40], [660, 1010], [300, 1020], + // [200, 150, 500], [200, 220, 500], + [200, 300, 500, settings.autoSalvage3 !== '是'], + [200, 380, 500, settings.autoSalvage4 !== '是'], + [340, 1000], [1720, 1015], [1320, 756], + [1840, 45, 1500], [1840, 45], [1840, 45] + ]; + + for (const coord of coords) { + const [x, y, delay = 1000, condition = true] = coord; // 默认值处理 + if (condition) { + click(x, y); + await sleep(delay); + } + } +})(); + diff --git a/repo/js/分解圣遗物 带背包过期弹窗自动点击/manifest.json b/repo/js/分解圣遗物 带背包过期弹窗自动点击/manifest.json new file mode 100644 index 000000000..41be3992c --- /dev/null +++ b/repo/js/分解圣遗物 带背包过期弹窗自动点击/manifest.json @@ -0,0 +1,13 @@ +{ + "manifest_version": 1, + "name": "选择级别 分解圣遗物 背包过期弹窗版", + "version": "1.0", + "description": "可选是否分解三四级圣遗物,附带打开背包时,自动点击过期物品弹窗", + "authors": [ + { + "name": "吉吉喵", + } + ], + "settings_ui": "settings.json", + "main": "main.js", +} \ No newline at end of file diff --git a/repo/js/分解圣遗物 带背包过期弹窗自动点击/settings.json b/repo/js/分解圣遗物 带背包过期弹窗自动点击/settings.json new file mode 100644 index 000000000..dc53c4470 --- /dev/null +++ b/repo/js/分解圣遗物 带背包过期弹窗自动点击/settings.json @@ -0,0 +1,20 @@ +[ + { + "name": "autoSalvage4", + "type": "select", + "label": "自动分解包括4星圣遗物(默认:是)", + "options": [ + "是", + "否" + ] + }, + { + "name": "autoSalvage3", + "type": "select", + "label": "自动分解包括3星圣遗物(默认:是)", + "options": [ + "是", + "否" + ] + }, +] \ No newline at end of file