Skip to main content

autourgos-cua-coordinate-tool

Framework: Autourgos Python License: Apache 2.0 Author

LLM-grounded UI coordinate finding for Autourgos computer-use agents. Give it a description ("the Submit button") and it returns where that element is — normalized to a 0-1000 scale, the same convention Gemini's computer-use API uses. It can auto-capture the current screen and auto-detect screen dimensions, or take an explicit screenshot/dimensions instead — both paths are always available.

from autourgos_cua_coordinate_tool import CoordinateFinder
from autourgos_openaichat import OpenAIChatModel

llm = OpenAIChatModel(model="gpt-4o")
finder = CoordinateFinder(llm)

# Automatic: capture the current screen and auto-detect its dimensions.
coord = finder.find("the Submit button")
x_px, y_px = coord.to_pixels()

# Custom: a specific screenshot and explicit dimensions.
coord = finder.find("the Submit button", "screenshot.png")
x_px, y_px = coord.to_pixels(1920, 1080)

Features

  • Provider-agnostic grounding — drives any vision-capable LLM shaped like autourgos-openaichat's or autourgos-responses's BaseLLM (invoke(prompt, files=, **overrides) / ainvoke(...)). No hard dependency on either package, and no coupling to one vision API.
  • Automatic and custom screenshots — omit image to auto-capture the current screen (optional mss dependency), or pass a specific file path/bytes yourself.
  • Automatic and custom screen dimensions — omit screen_width/screen_height to auto-detect them (free from an auto-capture, or via optional Pillow for a caller-supplied image), or pass them explicitly to force a specific conversion.
  • Gemini-style normalized coordinates — output is always 0-1000 on both axes regardless of screenshot resolution, matching Gemini computer-use's own convention, with .to_pixels() doing the documented denormalization.
  • Fails closed — an element the model can't find, or a response that can't be parsed, raises CoordinateNotFoundError instead of returning a fabricated coordinate.
  • Ready-made agent tool — make_find_coordinates_tool() wraps a CoordinateFinder as a standard autourgos-agent Tool for agent.add_tools(...).
  • Sync and async — find() / afind().

Table of Contents


Install

pip install autourgos-cua-coordinate-tool

For automatic screen capture (mss) and/or automatic image dimension detection (Pillow):

pip install 'autourgos-cua-coordinate-tool[capture]'   # auto-capture the screen
pip install 'autourgos-cua-coordinate-tool[images]'    # auto-detect a given image's size
pip install 'autourgos-cua-coordinate-tool[all]'       # both

Neither is required for the fully custom (caller-supplied image + dimensions) path.


Quick Start

from autourgos_cua_coordinate_tool import CoordinateFinder, CoordinateNotFoundError
from autourgos_openaichat import OpenAIChatModel

llm = OpenAIChatModel(model="gpt-4o")
finder = CoordinateFinder(llm)

try:
    coord = finder.find("the search input box")   # auto-captures the current screen
except CoordinateNotFoundError as exc:
    print("not found:", exc)
else:
    x_px, y_px = coord.to_pixels()                 # dimensions auto-detected from the capture
    print(f"click at ({x_px}, {y_px})")

Works the same with autourgos-responses model instances, or any object that exposes invoke(prompt, files=, **overrides) / ainvoke(...).


Automatic vs Custom

find(description, image=None, *, screen_width=None, screen_height=None, **overrides) supports both, and you can mix them freely:

image screen_width/screen_height Behavior
omitted (None) omitted Fully automatic — captures the current screen (mss), dimensions come free from the capture.
omitted (None) given Auto-captures the screen, but forces pixel conversion against the dimensions you passed.
given omitted Custom screenshot, dimensions auto-detected from it via Pillow if installed (falls back to None if not — to_pixels() then needs explicit dimensions).
given given Fully custom — no auto-capture, no auto-detection.
# Fully automatic
coord = finder.find("the Submit button")

# Custom screenshot, automatic dimensions (via Pillow)
coord = finder.find("the Submit button", "screenshot.png")

# Automatic screenshot, custom (forced) dimensions
coord = finder.find("the Submit button", screen_width=2560, screen_height=1440)

# Fully custom
coord = finder.find("the Submit button", "screenshot.png", screen_width=1920, screen_height=1080)

Async

coord = await finder.afind("the Submit button")   # auto-capture works here too

As an Agent Tool

from autourgos_agent import Agent
from autourgos_cua_coordinate_tool import CoordinateFinder, make_find_coordinates_tool

finder = CoordinateFinder(llm)

# Fully automatic (auto-captures the screen, auto-detects dimensions):
find_coordinates = make_find_coordinates_tool(finder)

# Custom instead:
find_coordinates = make_find_coordinates_tool(
    finder,
    screen_width=1920,
    screen_height=1080,
    screenshot_path="/tmp/screen.png",  # default when the agent omits image_path;
                                         # can also be a zero-arg callable for a
                                         # fresh path each call
)

agent = Agent(llm=my_llm)
agent.add_tools(find_coordinates)
result = agent.invoke("Click the Submit button")

The tool returns a dict: {"found": True, "x_norm": ..., "y_norm": ..., "x": ..., "y": ...} (pixel x/y only present when dimensions were configured or auto-detected), or {"found": False, "error": "..."} — including when auto-capture is requested but mss isn't installed.


Coordinate System

Every Coordinate is normalized to 0-1000 on both axes, independent of the screenshot's actual resolution — the same convention documented for Gemini's computer-use API:

actual_x = int(x_norm / 1000 * screen_width)
actual_y = int(y_norm / 1000 * screen_height)

Coordinate.to_pixels(screen_width=None, screen_height=None) implements this exactly — pass dimensions explicitly to force them (custom), or omit both to use whatever was auto-detected when the Coordinate was found (automatic).


Error Handling

CoordinateFinder.find()/afind() raise CoordinateNotFoundError — never a guessed coordinate — when:

  • the model explicitly reports the element isn't visible,
  • the response can't be parsed into a coordinate at all, or
  • a parsed coordinate falls outside the 0-1000 range.

Auto-capture (image=None) raises CaptureError instead if the optional mss dependency isn't installed.


API Reference

CoordinateFinder(llm, *, image_detail=None)

  • find(description, image=None, *, screen_width=None, screen_height=None, **overrides) -> Coordinate
  • afind(description, image=None, *, screen_width=None, screen_height=None, **overrides) -> Coordinate (async)

image is a file path or bytes, or omit it to auto-capture the current screen. **overrides are forwarded to the underlying llm.invoke()/ainvoke() call (e.g. temperature=).

Coordinate

  • x_norm: float, y_norm: float — 0-1000 normalized position
  • raw_response: str — the model's raw text, for debugging
  • screen_width, screen_height: Optional[int] — auto-detected (or explicitly passed) dimensions at find() time, if any
  • to_pixels(screen_width=None, screen_height=None) -> (int, int)

make_find_coordinates_tool(finder, *, screenshot_path=None, screen_width=None, screen_height=None, name="find_coordinates") -> Tool

Builds a find_coordinates(description, image_path=None) tool bound to finder. image_path omitted (and no screenshot_path configured) auto-captures the screen.

capture_screen() -> ScreenCapture / detect_image_size(image) -> Optional[(int, int)]

Lower-level helpers CoordinateFinder uses internally; exposed directly for other uses. capture_screen() raises CaptureError if mss isn't installed. detect_image_size() never raises — returns None if Pillow isn't installed or the image can't be read.


License

Apache License 2.0. See LICENSE.

Metadata

Release files for autourgos-cua-coordinate-tool 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autourgos-cua-coordinate-tool 1.1.0
File Size Uploaded
autourgos_cua_coordinate_tool-1.1.0.tar.gz 26.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autourgos-cua-coordinate-tool 1.1.0
File Interpreter ABI Platform
autourgos_cua_coordinate_tool-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.7 kB

Release files / autourgos_cua_coordinate_tool-1.1.0.tar.gz

Download URL autourgos_cua_coordinate_tool-1.1.0.tar.gz
Size 26.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c93223dfe552d639e7bcd0bac25b9009e8c780ea56befa75373d5218bb926caa
BLAKE2b-256 checksum
How to use checksums
5fa324c4b98d417ca97d72fddcdd25604d4c1c1dcd6424fc4ca5d47a67f7b4cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / autourgos_cua_coordinate_tool-1.1.0-py3-none-any.whl

Download URL autourgos_cua_coordinate_tool-1.1.0-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f92f76b1eeebac6dfd42648cb910f3d1b81cb49f1cb3dff4adfb8b1db47944e
BLAKE2b-256 checksum
How to use checksums
8b3e7f9dd85e047719d38f73ce92b3a753ff1ec215edc8edd293de028986bf8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

1.2.1

2 release files

This release

1.1.0 This release

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page