Files
wow/quest_follow.py
王鹏 33dc741fd9 add 硬件控制模块 (hardware_control.py) 并修复游戏状态扫描区域宽度
- 新增 wyhkm.dll 硬件盒子 COM 接口封装,支持键盘鼠标控制
- 修复 game_state_config.json 中 scan_region_width 过小导致截图越界的问题
- 添加鼠标路径录制器、硬件测试脚本等工具
- 更新多项配置默认值

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-15 12:15:00 +08:00

38 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
任务跟随:按固定间隔向游戏发送「跟随」与「交互」按键(使用 hw_ctrl 硬件盒子)。
"""
import time
from hardware_control import hw_ctrl
class QuestFollowBot:
"""每隔 interval_sec 秒依次按下跟随键、交互键;不读取游戏状态。"""
def __init__(
self,
follow_key="f",
interact_key="4",
interval_sec=3.0,
log_callback=None,
):
self.follow_key = (follow_key or "f").strip().lower() or "f"
self.interact_key = (interact_key or "4").strip().lower() or "4"
self.interval_sec = max(0.5, float(interval_sec))
self._last_cycle = 0.0
self._log = log_callback or (lambda _m: None)
def execute_logic(self, state):
"""state 可为 None仅用于与时间间隔配合的定时按键。"""
now = time.time()
if now - self._last_cycle < self.interval_sec:
return
self._last_cycle = now
try:
hw_ctrl.press(self.follow_key)
time.sleep(0.08)
hw_ctrl.press(self.interact_key)
self._log(f"➡️ 任务跟随: {self.follow_key}{self.interact_key}")
except Exception as e:
self._log(f"❌ 任务跟随按键失败: {e}")