利用python+win32獲取windows中任務中所有的窗口標題


# #!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021-06-15 18:06
# @Author : BruceLong
# @FileName: get_win_title.py
# @Email   : 18656170559@163.com
# @Software: PyCharm
# @Blog :http://www.cnblogs.com/yunlongaimeng/
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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM