diff --git a/repo/js/恢复默认键位设置/RecognitionObject/ConfirmButton.jpg b/repo/js/恢复默认键位设置/RecognitionObject/ConfirmButton.jpg new file mode 100644 index 00000000..4f5e3477 Binary files /dev/null and b/repo/js/恢复默认键位设置/RecognitionObject/ConfirmButton.jpg differ diff --git a/repo/js/恢复默认键位设置/RecognitionObject/RestoreButton.png b/repo/js/恢复默认键位设置/RecognitionObject/RestoreButton.png new file mode 100644 index 00000000..6576a954 Binary files /dev/null and b/repo/js/恢复默认键位设置/RecognitionObject/RestoreButton.png differ diff --git a/repo/js/恢复默认键位设置/RecognitionObject/SettingsButton.png b/repo/js/恢复默认键位设置/RecognitionObject/SettingsButton.png new file mode 100644 index 00000000..60e9d616 Binary files /dev/null and b/repo/js/恢复默认键位设置/RecognitionObject/SettingsButton.png differ diff --git a/repo/js/恢复默认键位设置/main.js b/repo/js/恢复默认键位设置/main.js new file mode 100644 index 00000000..7368b935 --- /dev/null +++ b/repo/js/恢复默认键位设置/main.js @@ -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(); +})(); diff --git a/repo/js/恢复默认键位设置/manifest.json b/repo/js/恢复默认键位设置/manifest.json new file mode 100644 index 00000000..d868e8d5 --- /dev/null +++ b/repo/js/恢复默认键位设置/manifest.json @@ -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" +} \ No newline at end of file