def _enumerate_windows(self, visible=True):
'''
Loops through the titles of all the "windows."
Spits out too much junk to to be of immediate use.
Keeping it here to remind me how the ctypes
callbacks work.
'''
# raise NotImplementedError('Not ready yet. Git outta here!')
titles = []
handlers = []
def worker(hwnd, lParam):
length = user32.GetWindowTextLengthW(hwnd) + 1
b = ctypes.create_unicode_buffer(length)
user32.GetWindowTextW(hwnd, b, length)
if visible and user32.IsWindowVisible(hwnd):
title = b.value
if title:
titles.append(title)
handlers.append(hwnd)
return True
WNDENUMPROC = ctypes.WINFUNCTYPE(BOOL,
HWND,
LPARAM)
if not user32.EnumWindows(WNDENUMPROC(worker), True):
raise ctypes.WinError()
else:
return handlers, titles
评论列表
文章目录