Python脚本获取Windows窗口标题,输出到命令行
Python语言:
#! /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))
EnumWindows(foo, 0)
lt = [t for t in titles if t]
lt.sort()
for t in lt:
print t
# -*- 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))
EnumWindows(foo, 0)
lt = [t for t in titles if t]
lt.sort()
for t in lt:
print t
作者:wenhai_zhang 发表于2009-12-14 20:15:00 原文链接
阅读:167 评论:0 查看评论