|
发表于 2016-11-9 11:10:43
|
显示全部楼层
栗子
- import os, time
- from win32gui import * #EnumWindows
- from win32process import GetWindowThreadProcessId
- titles = {}
- def foo(hwnd,mouse):
- if IsWindow(hwnd) and IsWindowEnabled(hwnd) and IsWindowVisible(hwnd):
- t = GetWindowText(hwnd)
- tid,pid = GetWindowThreadProcessId(hwnd)
- titles.setdefault(t,[])
- titles[t].append({'pid':pid,'hwnd':hwnd})
- os.popen('notepad')
- os.popen('notepad')
- time.sleep(2)
- EnumWindows(foo, 0)
- for t in titles:
- if t and len(titles[t])>1:
- print (t,titles[t])
- print ('end')
复制代码 |
|