Skip to content

Add exact window control tool#317

Closed
zengfanfan wants to merge 1 commit into
CursorTouch:mainfrom
zengfanfan:codex/exact-window-control
Closed

Add exact window control tool#317
zengfanfan wants to merge 1 commit into
CursorTouch:mainfrom
zengfanfan:codex/exact-window-control

Conversation

@zengfanfan

Copy link
Copy Markdown
Contributor

Summary

Adds a new exact Window tool for deterministic window workflows without fuzzy matching:

  • mode="find" returns matching windows with handle, PID, process, title, status, outer bounds, and client bounds;
  • mode="activate" brings an exact handle to foreground and verifies foreground readback;
  • mode="bounds" reports or sets exact outer/client bounds and returns actual geometry.

Motivation

The existing App tool is convenience-oriented and supports fuzzy name matching. This PR keeps that behavior unchanged and adds a separate exact path for workflows that must avoid selecting similarly titled windows.

Issue: #316

Public API

Window(mode="find", title="Untitled - Notepad", title_match="contains", process="notepad.exe")
Window(mode="activate", handle=123456, process_id=7890, process="notepad.exe")
Window(mode="bounds", handle=123456, process_id=7890, outer=[x, y, width, height])
Window(mode="bounds", handle=123456, process_id=7890, client=[x, y, width, height])

Matching is exact for handles/PIDs/process basenames and exact-or-contains for titles. Client bounds are converted to outer bounds using current frame/client deltas, then actual geometry is returned after Windows applies constraints.

Testing

Focused checks passed:

uv run pytest tests/test_exact_window_control.py
uv run ruff check src/windows_mcp/desktop/service.py src/windows_mcp/tools/window.py src/windows_mcp/tools/__init__.py tests/test_exact_window_control.py

Focused pytest result:

6 passed

Full repository pytest was also run and still shows the pre-existing baseline failures unrelated to this PR:

uv run pytest
# 324 passed, 3 failed in tests/test_iserror_compliance.py due missing shell/clipboard/registry exported tool functions

Notes

This PR is independent from deterministic drag PR #313 and guarded input PR #315. It does not include local planning documents or private consumer details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant