@
mingl0280 还是获取不到 /(ㄒoㄒ)/~~
现在的代码:
import win32api
import win32con
import win32gui
from pprint import pprint
def reset_window_pos():
hWndList = []
win32gui.EnumWindows(lambda hWnd, param: param.append(hWnd), hWndList)
count = 0
for hWnd in hWndList:
if win32gui.GetWindowText(hWnd) and win32gui.IsWindowVisible(hWnd):
dwStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_STYLE)
if dwStyle & win32con.WS_VISIBLE:
print(count,"-"*10)
print("GetWindowText:",win32gui.GetWindowText(hWnd))
print("win32con.WS_VISIBLE:",win32con.WS_VISIBLE)
print("GWL_STYLE:",win32gui.GetWindowLong(hWnd, win32con.GWL_STYLE))
print("GetWindowRect:",win32gui.GetWindowRect(hWnd))
count += 1
部分运行结果:
0 ----------
GetWindowText: QQ
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1777598464
GetWindowRect: (35, -535, 325, 5)
1 ----------
GetWindowText: F:\ME\beable\LockerTODO\try\win32try\
byPywin32.py - Sublime Text (UNREGISTERED)
win32con.WS_VISIBLE: 268435456
GWL_STYLE: 365887488
GetWindowRect: (-7, -7, 1288, 728)
………………………………………………………………………………………………
5 ----------
GetWindowText: 设置
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1811939328
GetWindowRect: (0, 1, 719, 486)
6 ----------
GetWindowText: 设置
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1798373376
GetWindowRect: (481, 80, 1214, 573)
7 ----------
GetWindowText: 邮件
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1811939328
GetWindowRect: (0, 1, 719, 656)
8 ----------
GetWindowText: 收件箱 - Outlook - 邮件
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1798373376
GetWindowRect: (0, 57, 733, 720)
9 ----------
GetWindowText: 电影和电视
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1811939328
GetWindowRect: (0, 1, 711, 426)
10 ----------
GetWindowText: 电影和电视
win32con.WS_VISIBLE: 268435456
GWL_STYLE: -1798373376
GetWindowRect: (108, 201, 834, 634)