pc.windows covers the desktop’s top-level windows, as the taskbar lists them.
Each is a Window. Bounds are screen pixels.
windows.list()
Every top-level window, front to back.
Returns list[Window].
windows.find()
The first window whose title contains title (case-insensitive) and whose
process is process. Doesn’t wait.
Window | None.
windows.wait_for()
Wait until a matching window exists, and return it.
| Parameter | Type | Default | Description |
|---|---|---|---|
title | str | None | None | Part of the title, case-insensitive. |
process | str | None | None | The program’s file name, such as "notepad.exe". |
timeout | float | None | 5000 | Milliseconds, at most 60,000. |
title, process or both.
Returns Window. Raises TimeoutError when none appears in time.
windows.focused
The window with focus.
Returns Window | None.
windows.focus(), minimize(), maximize(), restore()
Act on the window with id window_id.
Window afterwards, or None if it no longer exists.
windows.set_bounds()
Move and resize a window. An omitted field keeps its value; a maximized window
is restored first.
Window | None.
windows.close()
Ask the window to close, as its close button does.
None once it has closed. A window that declines (a “save changes?”
prompt) stays open, and is returned as it is.
Window
One top-level window. A dataclass.| Field | Type | Description |
|---|---|---|
id | str | The window’s id. |
title | str | Its title. |
process | str | The program’s file name, such as "notepad.exe". |
pid | int | Its process id. |
x, y, width, height | int | Its visible frame, in screen pixels. |
state | str | "normal", "minimized" or "maximized". |
focused | bool | Whether it has focus. |
window.center
Returns (x, y), the centre of the window.
window.focus(), minimize(), maximize(), restore(), close(), set_bounds()
The same as the windows methods, for this window.
None once it is gone. A Window holds
the values from when it was read: call windows.list() or the action again for
current ones.