Răsfoiți Sursa

脚本终极版本

zhensolid 7 luni în urmă
părinte
comite
60ec4d8284
1 a modificat fișierele cu 55 adăugiri și 32 ștergeri
  1. 55 32
      九剑九枪.ahk

+ 55 - 32
九剑九枪.ahk

@@ -1,38 +1,61 @@
-
-#Requires AutoHotkey v2.0
-;需要管理员权限运行
-L::
-{
-    KeyPress("q")
-    Sleep 3000
-    KeyPress("q")
-    Sleep 3000
-    KeyPress("{Tab}")
-    Sleep 1000
-    KeyPress("q")
-    Sleep 1000
-    KeyDown("r")
-    Sleep 2000
-    KeyUp("r")
-    Sleep 1000
-    KeyPress("2")
-    Sleep 1000
-    KeyPress("e")
-    Sleep 1000
-    KeyPress("1")
-}
+#Requires AutoHotkey v2.0
+#SingleInstance Force
+#HotIf WinActive("ahk_exe yysls.exe")
+
+global isRunning := false
+global currentStep := 1
+global interrupt := false
+
+global steps := [{ send: "q", sleep: 800 }, { send: "q", sleep: 800 }, { send: "{Tab}", sleep: 2100 }, { send: "q", sleep: 2000 }, { send: "{r down}", sleep: 1500 }, { send: "{r up}", sleep: 900 }, { send: "2", sleep: 1600 }, { send: "e", sleep: 1000 }, { send: "1", sleep: 2500 }, { send: "{Tab}", sleep: 1500 }, { send: "``", sleep: 900 }, { send: "``", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 1000 }, { send: "e", sleep: 800 }, { send: "q", sleep: 800 }, { send: "q", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 800 }, { send: "3", sleep: 1000 }, { send: "e", sleep: 700 }, { send: "{Tab}", sleep: 2000 }, { send: "q", sleep: 2000 }, { send: "{r down}", sleep: 1500 }, { send: "{r up}", sleep: 800 }, { send: "{Tab}", sleep: 0 }
+]
+
+L:: {
+    global isRunning, interrupt, currentStep
+
+    if isRunning {
+        return  ; 避免重复启动
+    }
 
-; 辅助函数:模拟按一下按键
-KeyPress(key) {
-    SendEvent key
+    interrupt := false
+    isRunning := true
+    currentStep := 1
+    ExecuteStep()  ; ⬅️ 直接启动第一步
 }
 
-; 辅助函数:按住某键
-KeyDown(key) {
-    SendEvent "{" key " down}"
+~Esc:: {
+    global interrupt, isRunning
+    if isRunning {
+        interrupt := true
+        ToolTip("脚本已中止")
+        SetTimer () => ToolTip(), -1000
+    }
 }
 
-; 辅助函数:放开某键
-KeyUp(key) {
-    SendEvent "{" key " up}"
+ExecuteStep() {
+    global steps, currentStep, isRunning, interrupt
+
+    if interrupt || currentStep > steps.Length {
+        isRunning := false
+        interrupt := false
+        currentStep := 1
+        return
+    }
+
+    step := steps[currentStep]
+    try {
+        Send(step.send)
+    } catch {
+        ToolTip("发送失败: " step.send)
+        SetTimer () => ToolTip(), -1000
+    }
+
+    currentStep++
+    if !interrupt && currentStep <= steps.Length {
+        SetTimer ExecuteStep, -step.sleep
+    } else {
+        isRunning := false
+        currentStep := 1
+    }
 }
+
+#HotIf