恢复默认键位设置 (#909)
* 恢复默认键位设置 * fix: 返回主界面. * fix: bgi_version --------- Co-authored-by: 寒烟 <2841974482@qq.com> Co-authored-by: 秋云 <physligl@gmail.com>
This commit is contained in:
BIN
repo/js/恢复默认键位设置/RecognitionObject/ConfirmButton.jpg
Normal file
BIN
repo/js/恢复默认键位设置/RecognitionObject/ConfirmButton.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
BIN
repo/js/恢复默认键位设置/RecognitionObject/RestoreButton.png
Normal file
BIN
repo/js/恢复默认键位设置/RecognitionObject/RestoreButton.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
repo/js/恢复默认键位设置/RecognitionObject/SettingsButton.png
Normal file
BIN
repo/js/恢复默认键位设置/RecognitionObject/SettingsButton.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
51
repo/js/恢复默认键位设置/main.js
Normal file
51
repo/js/恢复默认键位设置/main.js
Normal 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();
|
||||||
|
})();
|
||||||
15
repo/js/恢复默认键位设置/manifest.json
Normal file
15
repo/js/恢复默认键位设置/manifest.json
Normal 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"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user