From 92ae2776d7e694686801fb4339d4b49a15bdc377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=AA=E7=B1=BD=E9=98=B3=E5=A4=96=E5=A9=86?= <2915414902@qq.com> Date: Thu, 7 Nov 2024 23:06:10 +0800 Subject: [PATCH] Js SetTime --- repo/js/SetTime/main.js | 70 +++++++++++++++++++++++++++++++++++ repo/js/SetTime/manifest.json | 13 +++++++ repo/js/SetTime/settings.json | 7 ++++ 3 files changed, 90 insertions(+) create mode 100644 repo/js/SetTime/main.js create mode 100644 repo/js/SetTime/manifest.json create mode 100644 repo/js/SetTime/settings.json diff --git a/repo/js/SetTime/main.js b/repo/js/SetTime/main.js new file mode 100644 index 00000000..b4d0af0f --- /dev/null +++ b/repo/js/SetTime/main.js @@ -0,0 +1,70 @@ +(async function () { + setGameMetrics(1920, 1080, 2); // 设置游戏窗口大小和DPI + //拖动鼠标 + async function moveMouseSmoothly(x1, y1, x2, y2) { + const deltaX = x2 - x1; + const deltaY = y2 - y1; + const steps = Math.max(Math.abs(deltaX), Math.abs(deltaY)); + const stepX = deltaX / steps; + const stepY = deltaY / steps; + await moveMouseTo(x1, y1); + await leftButtonDown(); + for (let i = 1; i <= steps; i++) { + const newX = x1 + stepX * i; + const newY = y1 + stepY * i; + const validX = Math.round(newX); + const validY = Math.round(newY); + await moveMouseTo(validX, validY); + await sleep(10); + } + await leftButtonUp(); + } + //设定时间 + async function settime(time) { + const centerX = 1441; + const centerY = 501; + const radius = 100; + let angle; + angle = (90 + time * 15) % 360; + angle = angle >= 0 ? angle : 360 + angle; + const angle1 = (angle + 90) % 360; + const angle2 = (angle + 180) % 360; + const angle3 = (angle + 270) % 360; + const radians = angle * (Math.PI / 180); + const radians1 = angle1 * (Math.PI / 180); + const radians2 = angle2 * (Math.PI / 180); + const radians3 = angle3 * (Math.PI / 180); + const x = centerX + radius * Math.cos(radians); + const y = centerY + radius * Math.sin(radians); + const x1 = centerX + radius * Math.cos(radians1); + const y1 = centerY + radius * Math.sin(radians1); + const x2 = centerX + radius * Math.cos(radians2); + const y2 = centerY + radius * Math.sin(radians2); + const x3 = centerX + radius * Math.cos(radians3); + const y3 = centerY + radius * Math.sin(radians3); + + // 输出最终的坐标 + await sleep(2000); + await moveMouseSmoothly(centerX,centerY, x1,y1); + await sleep(2000); + await moveMouseSmoothly(centerX,centerY, x2,y2); + await sleep(2000); + await moveMouseSmoothly(centerX,centerY, x3,y3); + await sleep(2000); + await moveMouseSmoothly(centerX,centerY, x,y); + } + //设置时间 + log.info('设置时间到{xy}点',settings.time); + await keyPress("Escape"); + await sleep(1000); + await click(50,700); + await sleep(2000); + await settime(settings.time) + await sleep(3000); + await click(1500,1000);//确认 + await sleep(20000); + await keyPress("Escape"); + await sleep(2000); + await keyPress("Escape"); + await sleep(2000); +})(); \ No newline at end of file diff --git a/repo/js/SetTime/manifest.json b/repo/js/SetTime/manifest.json new file mode 100644 index 00000000..95a47bdb --- /dev/null +++ b/repo/js/SetTime/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/SetTime/settings.json b/repo/js/SetTime/settings.json new file mode 100644 index 00000000..554d13cd --- /dev/null +++ b/repo/js/SetTime/settings.json @@ -0,0 +1,7 @@ +[ + { + "name": "time", + "type": "input-text", + "label": "输入时间 [0-24] " + } +] \ No newline at end of file