"""Targeted scan for toolbar push buttons.
Physical Add button = logical screen (755, 257) × 1.25 = physical (944, 321)
"""
import requests

HOST = "http://127.0.0.1:8765"

print("Scanning x=850-1050, y=300-380 (physical)...")
found = []
for x in range(850, 1060, 8):
    for y in range(295, 390, 5):
        try:
            r = requests.post(f"{HOST}/info-at", json={"x": x, "y": y}, timeout=5)
            d = r.json()
            f = d.get("found", {})
            role = f.get("role", "")
            name = f.get("name", "")
            if role not in ("unknown", "", "internal frame"):
                found.append((x, y, role, name, f.get("bounds"), f.get("enabled")))
                print(f"  ({x:4d},{y:4d}): {role!r:20} name={name!r:15} bounds={f.get('bounds')}")
        except Exception as e:
            print(f"  ({x},{y}): {e}")

print(f"\nTotal non-frame elements: {len(found)}")
btns = [(x,y,r,n,b,e) for x,y,r,n,b,e in found if 'button' in r.lower()]
print(f"Buttons: {len(btns)}")
for b in btns:
    print(f"  {b}")
