- AALC 作为 submodule (vendor/aalc @ 7452fad), 不改其代码 - 低层工具走 AALC auto/ocr/模板匹配; 高层 run_task 跑 AALC 现成流程(子进程, 可强杀) - 常驻服务跑在交互桌面会话 + stdio bridge (token 认证), 取代每次截图注册计划任务 - 删除自写的截图/输入/OCR 后端 - 测试: FakeEngine 覆盖协议、任务生命周期、TCP+bridge 端到端 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""测试用引擎: 屏幕内容由测试脚本预设, 记录所有输入动作。"""
|
|
from .engine import Engine
|
|
|
|
|
|
class FakeEngine(Engine):
|
|
|
|
def __init__(self, frames=None, images=None):
|
|
# frames: 每次 ocr() 依次返回的 items 列表; 用完后停在最后一帧
|
|
self.frames = list(frames or [[]])
|
|
self.images = dict(images or {}) # name -> (x, y)
|
|
self.actions = []
|
|
self.shots = 0
|
|
|
|
def screenshot(self):
|
|
self.shots += 1
|
|
return {'path': 'fake/shot_%d.png' % self.shots, 'w': 1920, 'h': 1080}
|
|
|
|
def ocr(self):
|
|
shot = self.screenshot()
|
|
items = self.frames.pop(0) if len(self.frames) > 1 else self.frames[0]
|
|
return shot, [dict(it, score=it.get('score', 0.99)) for it in items]
|
|
|
|
def find_image(self, name, threshold=0.8, model='normal'):
|
|
return self.images.get(name)
|
|
|
|
def list_images(self, prefix=''):
|
|
return sorted(n for n in self.images if n.startswith(prefix))
|
|
|
|
def click(self, x, y, times=1):
|
|
self.actions.append(('click', int(x), int(y), int(times)))
|
|
|
|
def keypress(self, key):
|
|
self.actions.append(('key', key))
|
|
|
|
def type_text(self, text):
|
|
self.actions.append(('type', text))
|