imgclickflow 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.
- imgclickflow/__init__.py +97 -0
- imgclickflow/__main__.py +9 -0
- imgclickflow/cli.py +83 -0
- imgclickflow/core.py +2680 -0
- imgclickflow/paths.py +110 -0
- imgclickflow-0.1.0.dist-info/METADATA +158 -0
- imgclickflow-0.1.0.dist-info/RECORD +10 -0
- imgclickflow-0.1.0.dist-info/WHEEL +4 -0
- imgclickflow-0.1.0.dist-info/entry_points.txt +2 -0
- imgclickflow-0.1.0.dist-info/licenses/LICENSE +373 -0
imgclickflow/__init__.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
|
2
|
+
"""ImgClickFlow —— 基于图像识别的 Windows 桌面自动化助手。
|
|
3
|
+
|
|
4
|
+
典型用法::
|
|
5
|
+
|
|
6
|
+
import imgclickflow
|
|
7
|
+
imgclickflow.auto.click("保存")
|
|
8
|
+
|
|
9
|
+
``import`` 本身零副作用:不会打印任何内容,也不会创建任何目录。
|
|
10
|
+
首次真正需要落盘(截图 / 日志 / 报告 / 采集模板)时,才会在数据目录下
|
|
11
|
+
创建 ``templates`` / ``logs`` / ``error_snapshots`` / ``screenshots_author``。
|
|
12
|
+
|
|
13
|
+
数据目录解析优先级:
|
|
14
|
+
|
|
15
|
+
1. 环境变量 ``IMGCLICKFLOW_HOME``
|
|
16
|
+
2. 当前目录已存在 ``templates/`` —— 兼容"脚本与模板同目录"的老用法
|
|
17
|
+
3. ``%LOCALAPPDATA%\\ImgClickFlow``
|
|
18
|
+
|
|
19
|
+
需要固定数据目录时显式初始化::
|
|
20
|
+
|
|
21
|
+
imgclickflow.init(data_dir=r"D:\\my_flows")
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from .core import (
|
|
25
|
+
Config,
|
|
26
|
+
Flow,
|
|
27
|
+
auto,
|
|
28
|
+
capture_template_simple,
|
|
29
|
+
find_files,
|
|
30
|
+
first_last_day,
|
|
31
|
+
get_real_resolution,
|
|
32
|
+
get_screen_size,
|
|
33
|
+
get_scale_factor,
|
|
34
|
+
init,
|
|
35
|
+
key_down,
|
|
36
|
+
key_press,
|
|
37
|
+
key_press_plus,
|
|
38
|
+
key_up,
|
|
39
|
+
logger,
|
|
40
|
+
logical_to_real,
|
|
41
|
+
monthends,
|
|
42
|
+
mouse_left_click,
|
|
43
|
+
mouse_moveto,
|
|
44
|
+
mouse_right_click,
|
|
45
|
+
real_to_logical,
|
|
46
|
+
saystring,
|
|
47
|
+
scroll_mouse,
|
|
48
|
+
search,
|
|
49
|
+
timer_task,
|
|
50
|
+
timer_task_once,
|
|
51
|
+
timer_tasks,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def _resolve_version():
|
|
55
|
+
"""版本号的单一真相源是 pyproject.toml。从已安装元数据读取,源码直跑时回退。"""
|
|
56
|
+
try:
|
|
57
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
58
|
+
except ImportError: # Python < 3.8
|
|
59
|
+
return "0.0.0+source"
|
|
60
|
+
try:
|
|
61
|
+
return version("imgclickflow")
|
|
62
|
+
except PackageNotFoundError:
|
|
63
|
+
return "0.0.0+source"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
__version__ = _resolve_version()
|
|
67
|
+
|
|
68
|
+
__all__ = [
|
|
69
|
+
"__version__",
|
|
70
|
+
"Config",
|
|
71
|
+
"Flow",
|
|
72
|
+
"auto",
|
|
73
|
+
"init",
|
|
74
|
+
"logger",
|
|
75
|
+
"capture_template_simple",
|
|
76
|
+
"find_files",
|
|
77
|
+
"first_last_day",
|
|
78
|
+
"get_real_resolution",
|
|
79
|
+
"get_screen_size",
|
|
80
|
+
"get_scale_factor",
|
|
81
|
+
"key_down",
|
|
82
|
+
"key_press",
|
|
83
|
+
"key_press_plus",
|
|
84
|
+
"key_up",
|
|
85
|
+
"logical_to_real",
|
|
86
|
+
"monthends",
|
|
87
|
+
"mouse_left_click",
|
|
88
|
+
"mouse_moveto",
|
|
89
|
+
"mouse_right_click",
|
|
90
|
+
"real_to_logical",
|
|
91
|
+
"saystring",
|
|
92
|
+
"scroll_mouse",
|
|
93
|
+
"search",
|
|
94
|
+
"timer_task",
|
|
95
|
+
"timer_task_once",
|
|
96
|
+
"timer_tasks",
|
|
97
|
+
]
|
imgclickflow/__main__.py
ADDED
imgclickflow/cli.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
|
2
|
+
"""命令行入口。
|
|
3
|
+
|
|
4
|
+
安装后可直接使用:
|
|
5
|
+
|
|
6
|
+
imgclickflow doctor # 环境诊断
|
|
7
|
+
imgclickflow capture 保存 # 采集一个按钮模板
|
|
8
|
+
imgclickflow run my_flow.py # 运行流程脚本
|
|
9
|
+
imgclickflow help # 完整使用手册
|
|
10
|
+
|
|
11
|
+
也支持 ``python -m imgclickflow``。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _build_parser():
|
|
19
|
+
parser = argparse.ArgumentParser(
|
|
20
|
+
prog="imgclickflow",
|
|
21
|
+
description="基于图像识别的 Windows 桌面自动化助手",
|
|
22
|
+
epilog="数据目录默认位于 %LOCALAPPDATA%\\ImgClickFlow,"
|
|
23
|
+
"可用环境变量 IMGCLICKFLOW_HOME 覆盖。",
|
|
24
|
+
)
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--version", action="version",
|
|
27
|
+
version="%(prog)s {0}".format(_version()),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
sub = parser.add_subparsers(dest="command", metavar="<命令>")
|
|
31
|
+
|
|
32
|
+
sub.add_parser("doctor", help="环境诊断:分辨率、DPI、依赖、模板目录")
|
|
33
|
+
sub.add_parser("help", help="打印完整使用手册")
|
|
34
|
+
|
|
35
|
+
p_cap = sub.add_parser("capture", help="全屏截图,用于裁剪出按钮模板")
|
|
36
|
+
p_cap.add_argument("name", help="模板名称,例如:保存")
|
|
37
|
+
|
|
38
|
+
p_run = sub.add_parser("run", help="运行一个流程脚本")
|
|
39
|
+
p_run.add_argument("script", help="Python 脚本路径")
|
|
40
|
+
|
|
41
|
+
return parser
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _version():
|
|
45
|
+
from . import __version__
|
|
46
|
+
return __version__
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def main(argv=None):
|
|
50
|
+
parser = _build_parser()
|
|
51
|
+
args = parser.parse_args(argv)
|
|
52
|
+
|
|
53
|
+
if not args.command:
|
|
54
|
+
parser.print_help()
|
|
55
|
+
return 0
|
|
56
|
+
|
|
57
|
+
if args.command == "doctor":
|
|
58
|
+
from .core import _EnvChecker, _base_dir, _ensure_ready
|
|
59
|
+
_ensure_ready()
|
|
60
|
+
_EnvChecker.check()
|
|
61
|
+
_EnvChecker.check_templates()
|
|
62
|
+
return 0
|
|
63
|
+
|
|
64
|
+
if args.command == "help":
|
|
65
|
+
from .core import auto
|
|
66
|
+
auto.help()
|
|
67
|
+
return 0
|
|
68
|
+
|
|
69
|
+
if args.command == "capture":
|
|
70
|
+
from .core import capture_template_simple
|
|
71
|
+
return 0 if capture_template_simple(args.name) else 1
|
|
72
|
+
|
|
73
|
+
if args.command == "run":
|
|
74
|
+
import runpy
|
|
75
|
+
runpy.run_path(args.script, run_name="__main__")
|
|
76
|
+
return 0
|
|
77
|
+
|
|
78
|
+
parser.print_help()
|
|
79
|
+
return 2
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
sys.exit(main())
|