使用WindowMover文章和Nattee
Niparnan的博客文章中的提示,我设法创建了这个:
import win32conimport win32guidef isRealWindow(hWnd): '''Return True iff given window is a real Windows application window.''' if not win32gui.IsWindowVisible(hWnd): return False if win32gui.GetParent(hWnd) != 0: return False hasNoOwner = win32gui.GetWindow(hWnd, win32con.GW_OWNER) == 0 lExStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE) if (((lExStyle & win32con.WS_EX_TOOLWINDOW) == 0 and hasNoOwner) or ((lExStyle & win32con.WS_EX_APPWINDOW != 0) and not hasNoOwner)): if win32gui.GetWindowText(hWnd): return True return Falsedef getWindowSizes(): ''' Return a list of tuples (handler, (width, height)) for each real window. ''' def callback(hWnd, windows): if not isRealWindow(hWnd): return rect = win32gui.GetWindowRect(hWnd) windows.append((hWnd, (rect[2] - rect[0], rect[3] - rect[1]))) windows = [] win32gui.EnumWindows(callback, windows) return windowsfor win in getWindowSizes(): print win
您需要Win32 Extensions for
Python模块才能正常工作。
编辑:我发现
GetWindowRect比给出了更正确的结果
GetClientRect。来源已更新。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)