分享

pywintypes.error: (1400, 'GetClassName', '无效的窗口句柄。')

 融水公子 2024-04-25 发布于安徽
表白:黑白圣堂血天使,天剑鬼刀阿修罗。 
讲解对象:
/pywintypes.error: (1400, 'GetClassName', '无效的窗口句柄。')
作者:融水公子 rsgz
===

pywintypes.error: (1400, 'GetClassName', '无效的窗口句柄。')
根据句柄查找窗口标题的时候总是出现报错:pywintypes.error: (1400, 'GetClassName', '无效的窗口句柄。')
import win32gui

title = win32gui.GetWindowText(530790)
classname = win32gui.GetClassName(530790)

str = r"""
windows handler:{0}
title:{1}
classname:{2}
""".format(530790, title, classname)
print(str)
=======================
D:\python\python.exe C:/Users/Administrator/Desktop/桌面芒果代码/Auto_ps/001.py
Traceback (most recent call last):
  File "C:/Users/Administrator/Desktop/桌面芒果代码/Auto_ps/001.py", line 7, in <module>
    classname = win32gui.GetClassName(530790)
pywintypes.error: (1400, 'GetClassName', '无效的窗口句柄。')

我有两行赋值

这个报错就说明了第一行成功运行了 那么我们仅仅打印一行试试

import win32gui
title = win32gui.GetWindowText(530796)
str = r"""
windows handler:{0}
title:{1}
""".format(530796, title)
print(str)

==========================================================
windows handler:530796title:儿童内裤01.psd @ 100% (图层 3, RGB/8)
=== 
公众号:不浪仙人
谢谢大家的支持!可以点击我的头像,进入我的空间浏览更多文章呢。建议大家360doc[www.360doc.com]注册一个账号登录,里面真的有很多优秀的文章,欢迎大家的到来。
---
';

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多