Python pywin32获取当前所有打开窗口title

栏目: Python · 发布时间: 6年前

内容简介:EnumWindows = ctypes.windll.user32.EnumWindowsEnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))GetWindowText = ctypes.windll.user32.GetWindowTextW

Python pywin32获取当前所有打开窗口title


import ctypes

EnumWindows = ctypes.windll.user32.EnumWindows

EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))

GetWindowText = ctypes.windll.user32.GetWindowTextW

GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW

IsWindowVisible = ctypes.windll.user32.IsWindowVisible

titles = []

def foreach_window(hwnd, lParam):

if IsWindowVisible(hwnd):

length = GetWindowTextLength(hwnd)

buff = ctypes.create_unicode_buffer(length + 1)

GetWindowText(hwnd, buff, length + 1)

titles.append(buff.value)

return True

EnumWindows(EnumWindowsProc(foreach_window), 0)

print(titles)


以上所述就是小编给大家介绍的《Python pywin32获取当前所有打开窗口title》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Visual LISP程序设计

Visual LISP程序设计

李学志 / 清华大学 / 2006-5 / 29.00元

本书系统地介绍了AutoCAD最新版本(2006)的Visual LISP程序设计技术。全书共分13章。前3章介绍AutoLISP语言的基础知识,第4章介绍Visual LISP的开发环境,第5~7章介绍程序的编辑、调试和设计的方法与技巧,第8章介绍如何定义新的AutoCAD命令及创建图层、线型、文字样式、剖面线、尺寸标注等各种AutoCAD对象,以及如何实现参数化图形设计的方法和技术,第9章介绍......一起来看看 《Visual LISP程序设计》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换