pctr 0.3.0__tar.gz → 0.3.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pctr
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
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
5
  Author: Space-lab515
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pctr"
7
- version = "0.3.0"
7
+ version = "0.3.2"
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.2"
@@ -16,6 +16,12 @@ from pywinauto import Desktop
16
16
 
17
17
  DESCRIPTION = "Element-based Windows UI Automation CLI for AI agents."
18
18
 
19
+ try:
20
+ from importlib.metadata import version as _pkg_version
21
+ _VERSION = _pkg_version("pctr")
22
+ except Exception:
23
+ _VERSION = "unknown"
24
+
19
25
 
20
26
  def _fail(msg, code=2) -> NoReturn:
21
27
  """Print a clean one-line error and exit non-zero (no traceback)."""
@@ -36,30 +42,11 @@ def _iter_windows():
36
42
 
37
43
 
38
44
  def _find_window(title_re, process=None, timeout=5.0, index=0):
39
- rx_title = _compile(title_re, "title") if title_re else None
40
- desktop = Desktop(backend="uia")
41
- deadline = time.time() + timeout
42
- last = None
43
- while time.time() < deadline:
44
- matches = []
45
- for w in desktop.windows():
46
- try:
47
- t = w.window_text()
48
- except Exception:
49
- continue
50
- if rx_title and not rx_title.search(t):
51
- continue
52
- if process is not None and w.process_id() != process:
53
- continue
54
- matches.append(w)
55
- if len(matches) > index:
56
- return matches[index]
57
- last = matches
58
- time.sleep(0.25)
59
- raise SystemExit(
60
- "window not found: title_re=%r process=%r (saw %d match(es))"
61
- % (title_re, process, len(last or []))
62
- )
45
+ # Locate the HWND with Win32 first (fast, and never touches UIA providers of
46
+ # windows on *other* virtual desktops, which don't answer and can deadlock a
47
+ # full desktop enumeration). Then bind a UIA wrapper to just that one window.
48
+ h = _find_hwnd(title_re, process, timeout)
49
+ return Desktop(backend="uia").window(handle=h)
63
50
 
64
51
 
65
52
  def _enum_top_windows():
@@ -873,7 +860,8 @@ def _validate(args):
873
860
 
874
861
  def build_parser():
875
862
  ap = argparse.ArgumentParser(prog="pctr", description=DESCRIPTION, formatter_class=argparse.RawDescriptionHelpFormatter)
876
- sub = ap.add_subparsers(dest="cmd", required=True)
863
+ ap.add_argument("--version", action="version", version="pctr %s" % _VERSION)
864
+ sub = ap.add_subparsers(dest="cmd", required=False)
877
865
 
878
866
  w = sub.add_parser("windows", help="List top-level windows")
879
867
  w.add_argument("--filter", default=None)
@@ -1059,7 +1047,11 @@ def build_parser():
1059
1047
 
1060
1048
 
1061
1049
  def main():
1062
- args = build_parser().parse_args()
1050
+ ap = build_parser()
1051
+ args = ap.parse_args()
1052
+ if not getattr(args, "cmd", None):
1053
+ ap.print_help()
1054
+ return
1063
1055
  _validate(args)
1064
1056
  try:
1065
1057
  args.func(args)
@@ -1069,3 +1061,7 @@ def main():
1069
1061
  raise SystemExit(130)
1070
1062
  except Exception as e:
1071
1063
  _fail("%s: %s" % (type(e).__name__, e))
1064
+
1065
+
1066
+ if __name__ == "__main__":
1067
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pctr
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
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
5
  Author: Space-lab515
6
6
  License-Expression: MIT
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes