mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-22 04:29:49 +08:00
BIN
repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/Picture/image1.png
Normal file
BIN
repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/Picture/image1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/icon/Comfirm.png
Normal file
BIN
repo/js/分解圣遗物 带背包过期弹窗自动点击/assets/icon/Comfirm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
96
repo/js/分解圣遗物 带背包过期弹窗自动点击/main.js
Normal file
96
repo/js/分解圣遗物 带背包过期弹窗自动点击/main.js
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
13
repo/js/分解圣遗物 带背包过期弹窗自动点击/manifest.json
Normal file
13
repo/js/分解圣遗物 带背包过期弹窗自动点击/manifest.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "选择级别 分解圣遗物 背包过期弹窗版",
|
||||
"version": "1.0",
|
||||
"description": "可选是否分解三四级圣遗物,附带打开背包时,自动点击过期物品弹窗",
|
||||
"authors": [
|
||||
{
|
||||
"name": "吉吉喵",
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
"main": "main.js",
|
||||
}
|
||||
20
repo/js/分解圣遗物 带背包过期弹窗自动点击/settings.json
Normal file
20
repo/js/分解圣遗物 带背包过期弹窗自动点击/settings.json
Normal file
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"name": "autoSalvage4",
|
||||
"type": "select",
|
||||
"label": "自动分解包括4星圣遗物(默认:是)",
|
||||
"options": [
|
||||
"是",
|
||||
"否"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "autoSalvage3",
|
||||
"type": "select",
|
||||
"label": "自动分解包括3星圣遗物(默认:是)",
|
||||
"options": [
|
||||
"是",
|
||||
"否"
|
||||
]
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user