pctr 0.2.1__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pctr-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: pctr
3
+ Version: 0.3.0
4
+ Summary: Element-based Windows UI Automation CLI for AI agents. Find controls by name/type/id and click, type, hold, drag, and screenshot - no pixel coordinates.
5
+ Author: Space-lab515
6
+ License-Expression: MIT
7
+ Keywords: automation,windows,uia,pywinauto,desktop,agent,computer-use,rpa
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Environment :: Win32 (MS Windows)
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: Microsoft :: Windows
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Classifier: Topic :: System :: Networking
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: pywinauto>=0.6.8; platform_system == "Windows"
23
+ Requires-Dist: uiautomation>=2.0; platform_system == "Windows"
24
+ Requires-Dist: pyautogui>=0.9.54; platform_system == "Windows"
25
+ Requires-Dist: pydirectinput>=1.0.4; platform_system == "Windows"
26
+ Requires-Dist: pillow>=9.0; platform_system == "Windows"
27
+ Provides-Extra: vision
28
+ Requires-Dist: ultralytics>=8.2; extra == "vision"
29
+ Dynamic: license-file
30
+
31
+ # pctr
32
+
33
+ Element-based Windows UI Automation CLI for AI agents.
34
+
35
+ Instead of screenshotting and guessing pixel coordinates, `pctr` finds controls
36
+ by their **name / control type / automation id** and acts on them. Window moves,
37
+ DPI changes, and layout shifts don't break your script.
38
+
39
+ Built on `pywinauto` (UI Automation) with `pyautogui` / `pydirectinput` for raw
40
+ mouse and keyboard input. On top of UIA it also offers **OCR**
41
+ (`Windows.Media.Ocr`) and **YOLO-World** open-vocabulary detection for text and
42
+ objects that aren't exposed as controls.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install pctr
48
+ pip install "pctr[vision]" # adds ultralytics for `pctr look`
49
+ ```
50
+
51
+ Windows only.
52
+
53
+ ## Commands
54
+
55
+ | Command | What it does |
56
+ |---------|--------------|
57
+ | `pctr windows [--filter RE] [--process PID]` | List top-level windows (`pid=… \| title`). |
58
+ | `pctr tree --title RE [--depth N] [--limit N]` | Dump the UIA control tree of a window. |
59
+ | `pctr find --title RE [--name RE] [--limit N] [--nth N]` | List matching elements. |
60
+ | `pctr click --title RE --name RE [--method auto\|invoke\|mouse] [--dbl]` | Click an element. |
61
+ | `pctr set --title RE --name RE --text S` | Set a field via the UIA ValuePattern (exact, instant). |
62
+ | `pctr type [--title RE --name RE] --text S [--delay 0.03] [--chunk 1]` | Send keystrokes (see notes). |
63
+ | `pctr keys --keys "{ENTER}"` | Send a global key combo (pywinauto syntax). |
64
+ | `pctr hotkey --keys ctrl+s` | Send a modifier combo (prefer this over `keys "^s"`). |
65
+ | `pctr focus --title RE` | Bring a window to the foreground. |
66
+ | `pctr wait --title RE --name RE [--timeout S]` | Wait until an element exists. |
67
+ | `pctr shot [--title RE] --out PATH` | Screenshot the screen or a window. |
68
+ | `pctr size` | Print primary screen size as `WxH`. |
69
+ | `pctr desktop <action>` | Virtual desktops: `list` / `windows` / `where` / `on-current` / `next` / `prev` / `new` / `close` / `move-window`. |
70
+ | `pctr move --x N --y N` / `down` / `up` / `hold --ms N` | Raw mouse control (`--direct` for games). |
71
+ | `pctr drag --start x,y --end x,y [--duration S]` | Drag between two points. |
72
+ | `pctr keydown / keyup --key a` / `keyhold --key w --ms 1500` | Hold keyboard keys (`--direct` for games). |
73
+ | `pctr ocr [--title RE]` | OCR the screen/window; list words with boxes. |
74
+ | `pctr ocrfind --text RE` | OCR then list matches with click centers (single words). |
75
+ | `pctr ocrclick --text RE [--nth N]` | OCR then click a word. |
76
+ | `pctr look --for "a dog" [--title RE] [--conf X]` | YOLO-World detect objects by text prompt. |
77
+ | `pctr lookclick --for "a dog" [--nth N]` | Detect then click the top match. |
78
+ | `pctr skill [--install]` / `pctr setup` | Print/install the agent skill + an AGENTS.md section. |
79
+
80
+ Common filters: `--title` (regex), `--name` (regex), `--control-type`
81
+ (`Button`, `Edit`, `Pane`, `MenuItem`, …), `--auto-id`, `--nth`, `--process`.
82
+
83
+ `click`, `set`, `wait` accept **any** selector - `--name` is not required.
84
+ `tree`/`find` require a window selector (`--title` or `--process`).
85
+
86
+ ## The loop
87
+
88
+ ```bash
89
+ pctr tree --title "Notepad" --limit 60 # see what's clickable
90
+ pctr click --title "Notepad" --name "^File$"
91
+ pctr set --title "Notepad" --name "Text Editor" --text "hello"
92
+ ```
93
+
94
+ ## Virtual desktops
95
+
96
+ ```bash
97
+ pctr desktop list # desktops (#index, guid, [current], window count)
98
+ pctr desktop windows --desktop 1 # windows on desktop #1
99
+ pctr desktop where --title "App" # which desktop a window is on
100
+ pctr desktop on-current --title "App" # True / False
101
+ pctr desktop next | prev | new | close # switch (moves the active desktop)
102
+ pctr desktop move-window --title RE --to N
103
+ ```
104
+
105
+ - Switching uses the standard Win+Ctrl hotkeys and moves the **active** desktop
106
+ (you included). Add `--direct` if a game has focus.
107
+ - **Cross-desktop control:** UIA actions (`click --method invoke`, `set`) reach
108
+ windows on another desktop **without switching** (accessibility layer, not
109
+ screen input). Raw mouse/keys only affect the active desktop.
110
+ - **`move-window` is blocked on Windows 11** (third-party `MoveWindowToDesktop`
111
+ returns `Access denied`); it works on Windows 10.
112
+
113
+ ## Exit codes
114
+
115
+ - `0` success, `1` no match / window not found, `2` usage/validation error.
116
+ - Errors print one `error: …` line - no tracebacks.
117
+
118
+ ## Notes
119
+
120
+ - Prefer `set` (ValuePattern) over `type` for text fields - it can't drop or
121
+ reorder characters. `type`'s element path uses pywinauto `type_keys`, which
122
+ interprets `{ } + ^ % ~ ( )` as key syntax, so it is **not** literal.
123
+ - Global `type` / `keys` go to the OS-focused window - `pctr focus` first.
124
+ - Prefer `pctr hotkey --keys ctrl+s` over `keys "^s"`; the `^` modifier is
125
+ fragile through shells.
126
+ - `ocrfind`/`ocrclick` match one **word** at a time (Windows OCR tokenizes words).
127
+ - `look` reads its model from `--model` or the `PCTR_YOLO_MODEL` env var; progress
128
+ bars go to stderr so stdout stays parseable.
129
+ - Qt apps expose a rich tree including embedded webviews. Electron apps expose
130
+ only the window frame (use `focus` + global keys, or drive them over CDP).
131
+ - Games ignore synthetic input - pass `--direct` to mouse/key commands and focus
132
+ the game first.
133
+
134
+ ## License
135
+
136
+ MIT
pctr-0.3.0/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # pctr
2
+
3
+ Element-based Windows UI Automation CLI for AI agents.
4
+
5
+ Instead of screenshotting and guessing pixel coordinates, `pctr` finds controls
6
+ by their **name / control type / automation id** and acts on them. Window moves,
7
+ DPI changes, and layout shifts don't break your script.
8
+
9
+ Built on `pywinauto` (UI Automation) with `pyautogui` / `pydirectinput` for raw
10
+ mouse and keyboard input. On top of UIA it also offers **OCR**
11
+ (`Windows.Media.Ocr`) and **YOLO-World** open-vocabulary detection for text and
12
+ objects that aren't exposed as controls.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install pctr
18
+ pip install "pctr[vision]" # adds ultralytics for `pctr look`
19
+ ```
20
+
21
+ Windows only.
22
+
23
+ ## Commands
24
+
25
+ | Command | What it does |
26
+ |---------|--------------|
27
+ | `pctr windows [--filter RE] [--process PID]` | List top-level windows (`pid=… \| title`). |
28
+ | `pctr tree --title RE [--depth N] [--limit N]` | Dump the UIA control tree of a window. |
29
+ | `pctr find --title RE [--name RE] [--limit N] [--nth N]` | List matching elements. |
30
+ | `pctr click --title RE --name RE [--method auto\|invoke\|mouse] [--dbl]` | Click an element. |
31
+ | `pctr set --title RE --name RE --text S` | Set a field via the UIA ValuePattern (exact, instant). |
32
+ | `pctr type [--title RE --name RE] --text S [--delay 0.03] [--chunk 1]` | Send keystrokes (see notes). |
33
+ | `pctr keys --keys "{ENTER}"` | Send a global key combo (pywinauto syntax). |
34
+ | `pctr hotkey --keys ctrl+s` | Send a modifier combo (prefer this over `keys "^s"`). |
35
+ | `pctr focus --title RE` | Bring a window to the foreground. |
36
+ | `pctr wait --title RE --name RE [--timeout S]` | Wait until an element exists. |
37
+ | `pctr shot [--title RE] --out PATH` | Screenshot the screen or a window. |
38
+ | `pctr size` | Print primary screen size as `WxH`. |
39
+ | `pctr desktop <action>` | Virtual desktops: `list` / `windows` / `where` / `on-current` / `next` / `prev` / `new` / `close` / `move-window`. |
40
+ | `pctr move --x N --y N` / `down` / `up` / `hold --ms N` | Raw mouse control (`--direct` for games). |
41
+ | `pctr drag --start x,y --end x,y [--duration S]` | Drag between two points. |
42
+ | `pctr keydown / keyup --key a` / `keyhold --key w --ms 1500` | Hold keyboard keys (`--direct` for games). |
43
+ | `pctr ocr [--title RE]` | OCR the screen/window; list words with boxes. |
44
+ | `pctr ocrfind --text RE` | OCR then list matches with click centers (single words). |
45
+ | `pctr ocrclick --text RE [--nth N]` | OCR then click a word. |
46
+ | `pctr look --for "a dog" [--title RE] [--conf X]` | YOLO-World detect objects by text prompt. |
47
+ | `pctr lookclick --for "a dog" [--nth N]` | Detect then click the top match. |
48
+ | `pctr skill [--install]` / `pctr setup` | Print/install the agent skill + an AGENTS.md section. |
49
+
50
+ Common filters: `--title` (regex), `--name` (regex), `--control-type`
51
+ (`Button`, `Edit`, `Pane`, `MenuItem`, …), `--auto-id`, `--nth`, `--process`.
52
+
53
+ `click`, `set`, `wait` accept **any** selector - `--name` is not required.
54
+ `tree`/`find` require a window selector (`--title` or `--process`).
55
+
56
+ ## The loop
57
+
58
+ ```bash
59
+ pctr tree --title "Notepad" --limit 60 # see what's clickable
60
+ pctr click --title "Notepad" --name "^File$"
61
+ pctr set --title "Notepad" --name "Text Editor" --text "hello"
62
+ ```
63
+
64
+ ## Virtual desktops
65
+
66
+ ```bash
67
+ pctr desktop list # desktops (#index, guid, [current], window count)
68
+ pctr desktop windows --desktop 1 # windows on desktop #1
69
+ pctr desktop where --title "App" # which desktop a window is on
70
+ pctr desktop on-current --title "App" # True / False
71
+ pctr desktop next | prev | new | close # switch (moves the active desktop)
72
+ pctr desktop move-window --title RE --to N
73
+ ```
74
+
75
+ - Switching uses the standard Win+Ctrl hotkeys and moves the **active** desktop
76
+ (you included). Add `--direct` if a game has focus.
77
+ - **Cross-desktop control:** UIA actions (`click --method invoke`, `set`) reach
78
+ windows on another desktop **without switching** (accessibility layer, not
79
+ screen input). Raw mouse/keys only affect the active desktop.
80
+ - **`move-window` is blocked on Windows 11** (third-party `MoveWindowToDesktop`
81
+ returns `Access denied`); it works on Windows 10.
82
+
83
+ ## Exit codes
84
+
85
+ - `0` success, `1` no match / window not found, `2` usage/validation error.
86
+ - Errors print one `error: …` line - no tracebacks.
87
+
88
+ ## Notes
89
+
90
+ - Prefer `set` (ValuePattern) over `type` for text fields - it can't drop or
91
+ reorder characters. `type`'s element path uses pywinauto `type_keys`, which
92
+ interprets `{ } + ^ % ~ ( )` as key syntax, so it is **not** literal.
93
+ - Global `type` / `keys` go to the OS-focused window - `pctr focus` first.
94
+ - Prefer `pctr hotkey --keys ctrl+s` over `keys "^s"`; the `^` modifier is
95
+ fragile through shells.
96
+ - `ocrfind`/`ocrclick` match one **word** at a time (Windows OCR tokenizes words).
97
+ - `look` reads its model from `--model` or the `PCTR_YOLO_MODEL` env var; progress
98
+ bars go to stderr so stdout stays parseable.
99
+ - Qt apps expose a rich tree including embedded webviews. Electron apps expose
100
+ only the window frame (use `focus` + global keys, or drive them over CDP).
101
+ - Games ignore synthetic input - pass `--direct` to mouse/key commands and focus
102
+ the game first.
103
+
104
+ ## License
105
+
106
+ MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pctr"
7
- version = "0.2.1"
7
+ version = "0.3.0"
8
8
  description = "Element-based Windows UI Automation CLI for AI agents. Find controls by name/type/id and click, type, hold, drag, and screenshot - no pixel coordinates."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1 @@
1
+ __version__ = "0.3.0"