Scripts for getting window geometries.
Hiroyuki Komatsu
komatsu at taiyaki.org
Wed Dec 10 15:25:27 CST 2003
FYI, the following scripts obtain window geometries in each Windows
and X.
---- For Windows:
import win32api
import win32con
import win32gui
def EnumWindowsHandler(hwnd, resultList):
resultList.append(hwnd)
topWindows = []
win32gui.EnumWindows(windowEnumerationHandler, topWindows)
for window in topWindows:
rect = win32gui.GetWindowRect(window)
if win32gui.IsWindowVisible(window) and rect[2] > 0 and rect[3] > 0:
print win32gui.GetWindowText(window)
print win32gui.GetWindowRect(window)
---- For X:
import sys
import os
from Xlib import X, display
d = display.Display()
r = d.screen().root
wininfo = r.query_tree()
for child in wininfo.children:
if child.get_attributes().map_state == X.IsViewable:
print child.id,
print child.get_wm_name(),
g = child.get_geometry()
print "(%d, %d) %d x %d" % (g.x, g.y, g.width, g.height)
print
----
Hiro
More information about the ag-dev
mailing list