常见问题

安装与导入

ModuleNotFoundError: No module named 'winautox'

  • 确认 winautox 文件夹与脚本的父目录关系正确(见 安装)。
  • 在脚本所在目录运行:python demo.py
  • 或临时加入路径:
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))  # 使同级 winautox 可导入
from winautox import WinAuto

ImportError: DLL load failed / UIA 相关报错

  • 确认复制了完整目录,尤其是 winautox/uia/bin/UIAutomationClient_VC140_X64.dll
  • 安装 pip install comtypes pywin32
  • 用 64 位 Python 匹配 64 位系统。

找不到窗口

RuntimeError: 未找到窗口

  • 目标程序是否已打开?标题是否包含你写的关键字?
  • 用标题包含:WinAuto.find_hwnd(类名, '关键字'),不要一上来就要求全等。
  • 先枚举看一眼:
from winautox.utils import GetAllWindows
for h, cls, title in GetAllWindows():
    if title:
        print(h, cls, title)

找不到控件 / 点了没反应

  1. dump_windows_controls + print_windows_dump,核对 Name / Aid。
  2. 加大 depth(如 20~32)。
  3. 改用 mode='mouse' 试物理点击。
  4. 窗口是否被挡住、最小化?先 auto.activate()
  5. wait_ctrl(..., timeout=5) 等待控件出现。

中文输入乱码或没输入进去

  • 使用 auto.input(text, ctrl=edit, paste=True)(默认即剪贴板粘贴)。
  • 不要在 post 模式下硬输中文。

组合键无效

  • auto.hotkey(0x11, 0x41)(Ctrl+A),不要用 keys('{Ctrl}a')post
  • 确保已 WinAuto(hwnd) 绑定了窗口。

视觉 / OCR

报错或现象处理
视觉能力依赖未安装pip install -r winautox/requirements_vision.txt
找图总是空缩小 region;重截小模板;降低 sim
找色很卡安装 numba,或 prefer='mss'
OCR 报错pip install rapidocr_onnxruntime pillow numpy

消息列表 / im_client

winautox 不内置 IM SDK。im_client 必须自己传客户端类:

im = auto.im_client(client=YourIMClient, debug=False)

只做窗口点击、输入、剪贴板时,不需要 im_client

仍然不会?

建议按顺序看:

  1. 安装
  2. 快速开始
  3. 示例代码
  4. 调试与示例

会员 / 激活码 / 续费(授权相关)

软件授权、试用、购买、续费请看完整教程:

会员登录、激活码、购买与续费

摘要:

  • 每台电脑可免费试用 3 个月;同一台电脑不能用其他免费码再激活。
  • 激活码 200 元/个5 个 800 元;续费 1 月 20 / 3 月 55 / 6 月 105 / 年 200
  • 到期不续费:不能用新版本,旧版本一般仍可继续使用。
  • 操作入口:会员中心

客服:help@winautox.com

上一页找图找色采样返回总览 下一页会员登录与注册