microsoft / microsoft/winappCli

[Feature]: Add deterministic window bounds control to `winapp ui`

Open
#760 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
1.3k
Forks
80
Avg merge
3d 6h
Merged PRs (30d)
51

Description

### Is your feature request related to a problem? Please describe.

`winapp` CLI `0.2.2-nmetulev-ui-command.54` can discover windows with `winapp ui list-windows` and capture them with `winapp ui screenshot`, but it cannot move or resize a target window. Automated screenshot pipelines need every app at identical geometry—for example, 1440x900 at a known screen location. Today callers must add a PowerShell or C# P/Invoke helper around `SetWindowPos`/`MoveWindow`, which adds environment-specific glue and breaks an otherwise coherent `winapp ui` workflow.

This is useful beyond one screenshot pipeline: repeatable visual tests, documentation screenshots, demos, and general UI automation all benefit from deterministic window geometry.

### Describe the solution you'd like

Please add first-class window-bounds control under `winapp ui`. A unified command could look like:

```powershell
winapp ui set-window-bounds -a MyApp --x 100 --y 100 --width 1440 --height 900 --json
```

Separate move/resize commands would also be reasonable if they better match the CLI's conventions. The operation should:

- Support the existing `-a`/`--app` and `-w`/`--window` targeting model.
- Report no target, ambiguous targets, and invalid bounds through clear errors rather than silently choosing or succeeding.
- Return requested and actual bounds under `--json`, since Windows or the app may constrain the result.
- Define whether coordinates and dimensions use physical pixels or DPI-scaled units, and whether bounds describe the outer window or client area.
- Define behavior for minimized/maximized windows and app-enforced minimum-size constraints, including whether the command restores or clamps the window.

### Additional context

A screenshot automation step could remain entirely within the CLI:

```powershell
winapp ui set-window-bounds -a $app.ProcessId --x 100 --y 100 --width 1440 --height 900 --json
winapp ui screenshot -a $app.ProcessId --output "artifacts\$($app.Name).png" --json
```

This would make consistent capture across a large app suite straightforward without prescribing a particular Win32 implementation.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start from the existing `winapp ui list-windows` and `winapp ui screenshot` command entry points and review how they implement `-a`/`--app`, `-w`/`--window`, errors, and `--json`. Compare the requested behavior with the mentioned Windows `SetWindowPos`/`MoveWindow` APIs, then define targeting, DPI units, outer-versus-client bounds, and minimized or maximized behavior before implementation. Done means deterministic bounds control reports requested and actual geometry without silently selecting a target.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.