九剑九枪.ahk 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #Requires AutoHotkey v2.0
  2. #SingleInstance Force
  3. #HotIf WinActive("ahk_exe yysls.exe")
  4. global isRunning := false
  5. global currentStep := 1
  6. global interrupt := false
  7. 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 }
  8. ]
  9. L:: {
  10. global isRunning, interrupt, currentStep
  11. if isRunning {
  12. return ; 避免重复启动
  13. }
  14. interrupt := false
  15. isRunning := true
  16. currentStep := 1
  17. ExecuteStep() ; ⬅️ 直接启动第一步
  18. }
  19. ~Esc:: {
  20. global interrupt, isRunning
  21. if isRunning {
  22. interrupt := true
  23. ToolTip("脚本已中止")
  24. SetTimer () => ToolTip(), -1000
  25. }
  26. }
  27. ExecuteStep() {
  28. global steps, currentStep, isRunning, interrupt
  29. if interrupt || currentStep > steps.Length {
  30. isRunning := false
  31. interrupt := false
  32. currentStep := 1
  33. return
  34. }
  35. step := steps[currentStep]
  36. try {
  37. Send(step.send)
  38. } catch {
  39. ToolTip("发送失败: " step.send)
  40. SetTimer () => ToolTip(), -1000
  41. }
  42. currentStep++
  43. if !interrupt && currentStep <= steps.Length {
  44. SetTimer ExecuteStep, -step.sleep
  45. } else {
  46. isRunning := false
  47. currentStep := 1
  48. }
  49. }
  50. #HotIf