pythonwin-win32gui 窗口查找和遍历
来源:互联网 发布:ubuntu怎么用root登陆 编辑:程序博客网 时间:2024/06/07 02:16
#coding=utf-8__author__ = 'Administrator'__doc__ = '''pythonwin中win32gui的用法本文件演如何使用win32gui来遍历系统中所有的顶层窗口,并遍历所有顶层窗口中的子窗口'''import win32guifrom pprint import pprintdef gbk2utf8(s): return s.decode('gbk').encode('utf-8')def show_window_attr(hWnd): ''' 显示窗口的属性 :return: ''' if not hWnd: return #中文系统默认title是gb2312的编码 title = win32gui.GetWindowText(hWnd) title = gbk2utf8(title) clsname = win32gui.GetClassName(hWnd) print '窗口句柄:%s ' % (hWnd) print '窗口标题:%s' % (title) print '窗口类名:%s' % (clsname) print ''def show_windows(hWndList): for h in hWndList: show_window_attr(h)def demo_top_windows(): ''' 演示如何列出所有的顶级窗口 :return: ''' hWndList = [] win32gui.EnumWindows(lambda hWnd, param: param.append(hWnd), hWndList) show_windows(hWndList) return hWndListdef demo_child_windows(parent): ''' 演示如何列出所有的子窗口 :return: ''' if not parent: return hWndChildList = [] win32gui.EnumChildWindows(parent, lambda hWnd, param: param.append(hWnd), hWndChildList) show_windows(hWndChildList) return hWndChildListhWndList = demo_top_windows()assert len(hWndList)parent = hWndList[20]#这里系统的窗口好像不能直接遍历,不知道是否是权限的问题hWndChildList = demo_child_windows(parent)print('-----top windows-----')pprint(hWndList)print('-----sub windows:from %s------' % (parent))pprint(hWndChildList)
1 0
- pythonwin-win32gui 窗口查找和遍历
- pythonwin-win32gui 窗口查找和遍历
- Python使用win32gui.SetWindowPos置顶窗口
- PythonWin
- 查找标题已知的窗口句柄,遍历窗口控件句柄
- 查找标题已知的窗口句柄,遍历窗口控件句柄
- pythonwin 的 interactive 窗口无法正常启动的解决办法
- 窗口的枚举和查找
- 窗口的枚举和查找
- 遍历查找某个进程拥有的所有窗口
- 遍历查找某个进程拥有的所有窗口
- Pycharm和PythonWin——Python IDE杂谈
- Dreamweaver8 查找和替换窗口不见了解决办法
- 遍历和查找容器内的控件
- 二叉查找树的创建和遍历
- 二叉树的遍历和查找
- Delphi 查找标题已知的窗口句柄,遍历窗口控件句柄
- 查找窗口
- JAVA语言之全排列的递归实现
- 获取对象的接口信息(方法/属性/事件)(VB6代码)
- maven命令速查(自用)
- DBN+Spark+Forest type+RS Classification”的试验过程-2016.05.06
- extjs struts2 文件上传的备忘录 .
- pythonwin-win32gui 窗口查找和遍历
- ios 文本框变化 监听的3种方式
- Linux配置IP地址的方法
- navigationBar 设置关于setTranslucent
- 完整java开发中JDBC连接数据库代码和步骤
- PostgreSQL使用建议(非常实用)
- Linux系统编程基础知识-Linux进程地址空间和虚拟内存
- C++第5次博客
- Android中获取文件存储位置(内部存储或者扩展SD卡)