Files
37duAutomation/libs/desktopauto/desktopauto/__init__.py
T
puddy 1664821117 restore: 恢复 11-06~11-09 本地未提交改动
- libs: 新增 hr_sdk / hotel_report / dingtalk,更新 desktopauto
- controlplane-next: SDK 管理模块(controller/entity/migrations)与前端视图
- electron-shell: 插件同步、注册表、runner 调整
- plugins: XQ0035/XQ0041/XQ0042/XQ0045_XQ0046/XQ0048/XQ0076/XQ0078 等版本更新
- tests/tools: 新增 SDK 兼容性检查与打包工具(sdk_pack.py、sdk_compat_check.py)
2026-11-09 17:27:10 +08:00

92 lines
4.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""desktopauto —— 屏幕识图 / 文字识别 / 鼠标键盘 工具库(面向无元素树的桌面自动化)。
只依赖 opencv-python + numpy + pillow(OCR 另需 rapidocr + onnxruntime),
鼠标键盘窗口全部走 ctypes 调系统 API,不依赖 pyautogui / pywin32 / 任何底座代码。
一次完整操作通常是:
from desktopauto import Screen
s = Screen(window="钉钉") # 限定窗口
s.activate()
s.click("img/chat_input.png") # 识图点击
s.paste("排班识别,水庄大鹅……") # 写剪贴板 + Ctrl+V(中文最稳)
s.hotkey("ctrl", "enter") # 组合键
s.wait_stable_text = s.wait_text("发送成功") # 文字确认
分组:
截图 grab / screenshot
识图 find / find_all / find_any / exists / wait / click / click_at
文字 read_text / recognize / find_text / find_all_text / text_exists /
wait_text / click_text
输入 paste / type_text / press / hotkey / key_down / key_up
鼠标 scroll / drag(click 已含左/右/中键与连击)
窗口 list_windows / find_window(s) / wait_window / child_windows /
window_info / window_rect / activate_window
颜色差异 find_color / find_colors / diff / diff_ratio
离线 mark(在图片上标注命中,不碰屏幕)
异常约定:
模板不存在/无法解码、窗口找不到、依赖缺失 → RuntimeError(配置错误,需要修);
图/文字没匹配到 → None / False(业务上的「不存在」,不是异常)。
"""
from . import clipboard, colors, fs, keys, ocr, process
from ._win32 import click_at
from .capture import screenshot
from .colors import ColorMatch, diff_ratio, find_colors
from .process import (is_running, kill_process, launch, list_processes, open_path,
open_url, run_or_open, wait_process)
from .marking import mark, summarize
from .matcher import Match
from .ocr import TextItem, match_text, recognize
from .screen import (
Screen, click, click_image, click_text, diff, drag, exists, find, find_all,
find_all_text, find_any, find_color, find_text, hotkey, hover, hover_image,
hover_text, image_exists, move_mouse, ocr_available, ocr_text,
ocr_text_with_position, paste, press, read_text, scroll, send_keys, sleep,
text_exists, type_text, wait, wait_any, wait_all, wait_gone, wait_image,
wait_text, wait_text_exists,
)
from .window import (
Window, activate_window, child_windows, close_window, find_window, find_windows,
foreground_window, get_window, list_windows, wait_window, window_info, window_rect,
)
__all__ = [
# 门面
"Screen",
"Match",
"TextItem",
"ColorMatch",
# 截图 / 坐标点击
"screenshot", "click_at",
# 识图 / 条件判断 / 等待
"find", "find_all", "find_any", "exists", "wait", "click",
"wait_gone", "wait_any", "wait_all", "hover", "hover_text",
# 文字
"read_text", "recognize", "match_text", "find_text", "find_all_text",
"text_exists", "wait_text", "click_text", "ocr_available", "ocr",
"ocr_text", "ocr_text_with_position",
# RPA 指令别名
"image_exists", "wait_image", "click_image", "hover_image", "wait_text_exists",
# 输入
"paste", "type_text", "press", "hotkey", "send_keys", "keys", "clipboard",
# 鼠标 / 等待
"scroll", "drag", "move_mouse", "sleep",
# 文件与文件夹
"fs",
# 颜色 / 差异
"find_color", "find_colors", "diff", "diff_ratio", "colors",
# 窗口
"Window", "get_window", "foreground_window", "activate_window", "close_window",
"list_windows", "find_window", "find_windows", "wait_window", "child_windows",
"window_info", "window_rect",
# 进程:运行或打开 / 终止程序
"run_or_open", "launch", "open_path", "open_url",
"list_processes", "is_running", "wait_process", "kill_process", "process",
# 离线
"mark", "summarize",
]
__version__ = "0.4.0"