Image-Based Fallback¶
Image matching is the fallback path for controls that UIA and Win32 cannot see. It uses OpenCV template matching and optional OCR through Tesseract.
Install¶
OCR also requires the Tesseract executable to be installed separately.
Capture A Template¶
Use Ctrl+Click in the picker to save a PNG template.
Use ImageLocator¶
from dolphin_desktop import ImageLocator
button = ImageLocator("templates/submit.png", threshold=0.9)
button.wait_for(timeout=10)
button.click()
Find without clicking:
Find all matches:
Scope To A Window¶
window.image(...) restricts matching to the window bounding box when Dolphin can read it.
Locator Fallback¶
Use a normal selector first and an image only as the last resort:
from dolphin_desktop import ImageLocator
win.locator(
auto_id="btnSubmit",
fallback=[{"title": "Submit", "control_type": "Button"}],
image_fallback=ImageLocator("templates/submit.png", threshold=0.9),
).click()
OCR And Screen Helpers¶
from dolphin_desktop import Screen
img = Screen.screenshot()
img.save("screen.png")
text = Screen.text()
point = Screen.find_text("Submitted")
Tips¶
- Keep templates small and specific.
- Capture templates at the same DPI and theme used by CI.
- Prefer UIA or Win32 selectors when available.
- Use OCR for broad verification, not as the first choice for precise controls.