PyClickerRPA 0.1.0__py3-none-any.whl

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.
autoclicker/run.py ADDED
@@ -0,0 +1,64 @@
1
+ """Headless CLI runner: python -m autoclicker.run <task.json> [--window TITLE].
2
+
3
+ Loads a task (C++ or Python .json, same schema) and executes it against a target
4
+ window (by title substring) or the full screen, printing the engine log.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import argparse
9
+ import sys
10
+ import time
11
+
12
+ from autoclicker.models import Task
13
+ from autoclicker.runner import RunnerCallbacks, TaskRunner
14
+
15
+
16
+ class ConsoleCallbacks(RunnerCallbacks):
17
+ def step_started(self, index, description):
18
+ print(f"[{index + 1}] {description}")
19
+
20
+ def log(self, msg):
21
+ print(msg)
22
+
23
+ def match_found(self, x, y, confidence):
24
+ pass
25
+
26
+
27
+ def main(argv=None) -> int:
28
+ parser = argparse.ArgumentParser(prog="autoclicker.run", description="Run an AutoClicker task headless.")
29
+ parser.add_argument("task", help="Path to a .json task file")
30
+ parser.add_argument("--window", help="Target window title (substring, case-insensitive)")
31
+ args = parser.parse_args(argv)
32
+
33
+ from autoclicker.dpi import set_dpi_aware
34
+ set_dpi_aware()
35
+
36
+ task = Task.load_from_file(args.task)
37
+ if not task.steps:
38
+ print(f"任务为空或加载失败: {args.task}", file=sys.stderr)
39
+ return 1
40
+
41
+ hwnd = None
42
+ if args.window:
43
+ from autoclicker.windows import find_by_title
44
+ info = find_by_title(args.window)
45
+ if info is None:
46
+ print(f"找不到窗口: {args.window}", file=sys.stderr)
47
+ return 2
48
+ hwnd = info.hwnd
49
+ print(f"目标窗口: {info.title} ({info.width}x{info.height})")
50
+
51
+ runner = TaskRunner(task, target_hwnd=hwnd, callbacks=ConsoleCallbacks())
52
+ runner.start()
53
+ try:
54
+ while runner.is_alive():
55
+ time.sleep(0.2)
56
+ except KeyboardInterrupt:
57
+ print("\n中断,停止任务...")
58
+ runner.stop()
59
+ runner.join(timeout=5)
60
+ return 0
61
+
62
+
63
+ if __name__ == "__main__":
64
+ raise SystemExit(main())