恢复默认键位设置 (#909)
Some checks failed
Build repo.json / build (18.x) (push) Has been cancelled
Build repo.json / upload (push) Has been cancelled

* 恢复默认键位设置

* fix: 返回主界面.

* fix: bgi_version

---------

Co-authored-by: 寒烟 <2841974482@qq.com>
Co-authored-by: 秋云 <physligl@gmail.com>
This commit is contained in:
214-hanyan
2025-05-23 14:59:32 +08:00
committed by GitHub
parent a3cc91f704
commit 61484043a3
5 changed files with 66 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,51 @@
const SettingsButtonRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/SettingsButton.png"), 0.8, 650, 100, 300);
const RestoreButtonRo = RecognitionObject.TemplateMatch(file.ReadImageMatSync("RecognitionObject/RestoreButton.png"), 1400, 950, 130, 130);
(async function () {
// 恢复默认键位设置
async function KeyBindlings() {
await genshin.returnMainUi();
await sleep(2000);
keyPress("ESCAPE");
await sleep(2000);
let SettingsButton = captureGameRegion().find(SettingsButtonRo);
if (SettingsButton.isExist()) {
log.info("识别到设置按钮");
SettingsButton.click();
await sleep(2000);
let captureRegion = captureGameRegion();
let resList = captureRegion.findMulti(RecognitionObject.ocr(100, 100, 300, 300));
for (let i = 0; i < resList.count; i++) {
let res = resList[i];
if (res.text.includes("Key") || res.text.includes("Bindings") || res.text.includes("按键") || res.text.includes("按鍵")) {
res.click();
await sleep(2000);
let RestoreButton = captureGameRegion().find(RestoreButtonRo);
if (RestoreButton.isExist()) {
log.info("识别到恢复默认按钮");
RestoreButton.click();
await sleep(1500);
let captureRegion = captureGameRegion();
let resList = captureRegion.findMulti(RecognitionObject.ocr(1000, 720, 340, 60));
for (let i = 0; i < resList.count; i++) {
let res = resList[i];
if (res.text.includes("确认")) {
log.info("识别到确认按钮");
res.click();
await sleep(2000);
}
}
}
}
}
}
}
// 执行函数
await KeyBindlings();
await genshin.returnMainUi();
})();

View File

@@ -0,0 +1,15 @@
{
"manifest_version": 1,
"name": "恢复默认键位",
"version": "1.0",
"bgi_version": "0.45.0",
"description": "用于恢复默认键位",
"authors": [
{
"name": "寒烟",
"link": "https://github.com/214-hanyan"
}
],
"settings_ui": "settings.json",
"main": "main.js"
}