Python获取Windows窗口标题并输出的脚本方法,python窗口,本文Python获取Wi


本文Python获取Windows窗口标题并输出的脚本方法,可以简单的理解为python 获取窗口标题。是要通过python方法获取到所有Windows窗口的标题,并把这些获取到的标题内容输出到命令行中的实现。

Python获取Windows窗口标题并输出的源码如下:

#! /usr/bin/env python# -*- coding: utf-8 -*-from win32gui import *titles = set()def foo(hwnd,nouse):  #去掉下面这句就所有都输出了,但是我不需要那么多  if IsWindow(hwnd) and IsWindowEnabled(hwnd) and IsWindowVisible(hwnd):    titles.add(GetWindowText(hwnd))#www.iplaypy.comEnumWindows(foo, 0)lt = [t for t in titles if t]lt.sort()for t in lt:  print t

能过python方法可以获取到很多你想要知道的信息,比如之前的文章中有如何用Python方法获取图片的准确尺寸就很实用。

编橙之家文章,

评论关闭