- ADB client (connect, tap, swipe, screencap, app control) - Vision module (in-memory screenshot + OpenCV template matching) - Action loader (auto-discovers .py files in actions/) - Engine (screenshot → detect → act loop with YAML playbook) - 12 built-in actions: tap, click, wait, swipe, find, find_and_click, wait_until, click_seq, keyevent, app, log - Example custom action template - Debug screenshot tool for template creation - Detailed plan.md with 20 actions across 9 phases - Sample playbook with 10 steps
30 lines
996 B
Python
30 lines
996 B
Python
"""Action: wait_until — wait for a template to appear (with timeout)."""
|
|
import os
|
|
import time
|
|
|
|
|
|
class Action:
|
|
name = "wait_until"
|
|
|
|
def run(self, ctx, params):
|
|
template = params["template"]
|
|
confidence = params.get("confidence", 0.8)
|
|
timeout = params.get("timeout", 30)
|
|
poll = params.get("poll_interval", 1)
|
|
|
|
tmpl_dir = ctx.get("_templates_dir",
|
|
os.path.join(os.path.dirname(__file__), "..", "templates"))
|
|
tpl_path = os.path.join(tmpl_dir, template)
|
|
|
|
deadline = time.time() + timeout
|
|
while time.time() < deadline:
|
|
ctx["vision"].capture()
|
|
pos = ctx["vision"].find_template(tpl_path, confidence)
|
|
if pos is not None:
|
|
ctx["log"].info("wait_until(%s) → found at %s", template, pos)
|
|
return pos
|
|
time.sleep(poll)
|
|
|
|
ctx["log"].warning("wait_until(%s) → timeout after %.0fs", template, timeout)
|
|
return None
|