- 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
28 lines
953 B
Python
28 lines
953 B
Python
"""Action: find_and_click — locate a template image and tap it."""
|
|
import os
|
|
|
|
|
|
class Action:
|
|
name = "find_and_click"
|
|
|
|
def run(self, ctx, params):
|
|
template = params["template"]
|
|
confidence = params.get("confidence", 0.8)
|
|
region = params.get("region")
|
|
offset_x = params.get("offset_x", 0)
|
|
offset_y = params.get("offset_y", 0)
|
|
|
|
tmpl_dir = ctx.get("_templates_dir",
|
|
os.path.join(os.path.dirname(__file__), "..", "templates"))
|
|
tpl_path = os.path.join(tmpl_dir, template)
|
|
|
|
pos = ctx["vision"].find_template(tpl_path, confidence, region)
|
|
if pos is None:
|
|
ctx["log"].info("find_and_click(%s) → not found, skipping", template)
|
|
return None
|
|
|
|
cx, cy = pos[0] + offset_x, pos[1] + offset_y
|
|
ctx["adb"].tap(cx, cy)
|
|
ctx["log"].info("find_and_click(%s) → tap(%d, %d)", template, cx, cy)
|
|
return (cx, cy)
|