Skip to content

let your agent control your phone

feat: add screenshot pixel coordinate tapping

ShawnPana6fd515126be7
diff --git a/install.md b/install.md
index f3a57f9..eb84545 100644
--- a/install.md
+++ b/install.md
@@ -7,7 +7,7 @@ Use once. For phone work, read `SKILL.md`.
- macOS Sequoia+ with iPhone Mirroring paired to the phone (open the app once
manually to pair — pairing prompts need the physical phone).
- Python 3.12+ with pyobjc (`pip install pyobjc-framework-Quartz
- pyobjc-framework-Vision pyobjc-framework-AppKit`).
+ pyobjc-framework-Vision`; AppKit is bundled with the macOS Python bridge here).
- The terminal app needs two permissions in System Settings > Privacy &
Security. **The toggles require the user:**
- **Accessibility** — taps and keystrokes. Takes effect immediately.
diff --git a/src/phone_harness/helpers.py b/src/phone_harness/helpers.py
index 4b10bbd..9bc0b1b 100644
--- a/src/phone_harness/helpers.py
+++ b/src/phone_harness/helpers.py
@@ -97,6 +97,33 @@ def screenshot(path=None):
return p
+def image_point(x, y, image_size=None):
+ """Convert a screenshot pixel point to a global screen point.
+
+ Pass the pixel coordinates observed in the most recent screenshot. The
+ current window and capture size are queried every call so window movement,
+ resizing, and Retina/non-Retina captures are handled correctly.
+ """
+ info = screen_info()
+ iw, ih = image_size or info["img_px"]
+ win = info["window"]
+ if iw <= 0 or ih <= 0:
+ raise ValueError("image dimensions must be positive")
+ return (win["x"] + x * win["w"] / iw,
+ win["y"] + y * win["h"] / ih)
+
+
+def tap_image_point(x, y, image_size=None):
+ """Tap a point identified in screenshot pixel coordinates.
+
+ This is for icon-only controls that OCR cannot locate. It converts the
+ point using the current window geometry, then sends the normal tap event.
+ """
+ gx, gy = image_point(x, y, image_size=image_size)
+ tap(gx, gy)
+ return {"image": {"x": x, "y": y}, "screen": {"x": gx, "y": gy}}
+
+
# --- did we interrupt the user ----------------------------------------------
def focus_probe():