辅助与许可

本章是「配套工具箱」:读笔记弹窗、识别新弹出的窗口、检查激活码、查看视觉依赖是否装好。
日常点击/输入仍以 方法手册其它章节 为主。

方法一览

符号说明
NoteContentParser笔记/图文剪贴板解析器类
read_note_window(...)等待笔记窗 → 全选复制 → 解析 → 可选关闭
snapshot_hwnds(class_names)点击前快照顶层 HWND
wait_new_toplevel(class_names, before, ...)等待点击后新顶层窗
authenticate / check_license / device_id / license_info许可
WinAuto.vision_status / perf_status视觉依赖与性能探测
WinAuto.snapshot_popups / wait_popup / wait_chrome_popup弹窗(亦见 滚动与窗口

场景 A:点开笔记后读取图文(逐步)

  1. 在聊天里用 click / click_bubble 点开笔记类消息。
  2. 立刻调用 read_note_window,让它自动:等窗口 → 全选复制 → 解析 →(可选)关闭。
  3. 看返回的 items:按顺序排列的文字 / 图片 / 文件。
# -*- coding: utf-8 -*-
from winautox import WinAuto, read_note_window
import time

# …先 bind 主窗口,点开笔记消息…
# auto.click_bubble(note_ctrl)
# time.sleep(0.2)

# ClassName 务必改成你真实的笔记窗(可用软件枚举窗口确认)
result = read_note_window(
    note_class_name='NoteWnd',
    timeout=5.0,
    close_after=True,
)

if not result.get('success'):
    print('读取失败:', result.get('error'))
else:
    print('标题:', result.get('title'))
    print('全文:', result.get('text'))
    for item in result.get('items') or []:
        # type: text / image / file
        print(item['type'], '=>', item['content'])
参数默认说明
note_class_name'NoteWnd'笔记窗 ClassName(按实际软件改)
timeout5.0等待出现秒数
close_afterTrue读完是否 Alt+F4 关闭
extra_classesNone备选类名列表
popup_hwnd0已定位 HWND(可跳过等待)

返回字段:titletextfilesitemsraw_clipboardsuccesserror

复杂解析可直接用 NoteContentParser(源码 winautox.auto.note_parser)。


场景 B:点击后弹出新窗口(差集定位)

为什么需要差集?
桌面上可能已经有同类型旧窗口。若「点击后再按 ClassName 找第一个」,容易绑错。
正确做法:点击记下已有 HWND → 点击 → 等「新出现」的那个。

# -*- coding: utf-8 -*-
from winautox import WinAuto, snapshot_hwnds, wait_new_toplevel
import time

auto = WinAuto(...)  # 已绑定主窗口
auto.activate()

classes = ['Chrome_WidgetWin_0', 'NativeNoteWnd']  # ← 改成实际弹窗类名
before = snapshot_hwnds(classes)

auto.click_bubble(note_ctrl)   # 或 auto.click(name='...')
hwnd = wait_new_toplevel(classes, before, timeout=5.0)

if not hwnd:
    print('没有新窗口:检查类名、点击是否成功、超时')
else:
    print('新窗口 hwnd=', hwnd)
    popup = WinAuto(hwnd, mode='uia')
    popup.activate()
    time.sleep(0.3)
    # 在 popup 上继续 find / copy_content / ...

WinAuto 上也有 snapshot_popups / wait_popup / wait_chrome_popup,语义类似,见 滚动与窗口


场景 C:激活码与许可

from winautox import authenticate, check_license, device_id, license_info

print('设备 ID:', device_id())
ok = authenticate('你的激活码')   # True / False
print('激活结果:', ok)
print('当前许可:', check_license())
print('许可详情:', license_info())

未授权时部分能力可能受限。会员购买与续费见 会员相关


场景 D:视觉依赖装好了吗?

找图 / OCR 前先探测,避免「调了半天花在没装依赖上」:

from winautox import WinAuto

print(WinAuto.vision_status())
# 关注 dxcam / numba / mss 等字段与 warn 提示

print(WinAuto.perf_status())

完整找图找色 API 见 找图找色采样


和入门文档的关系

你想…去看
第一次跑通安装快速开始
弹窗例子示例代码 · 示例 6
剪贴板图文剪贴板