def foreach_child(self):
def callback(hwnd, window_hwnd):
classname = win32gui.GetClassName(hwnd).lower()
buffer_len = win32gui.SendMessage(hwnd, win32con.WM_GETTEXTLENGTH, 0, 0) + 1
text = array('b', b'\x00\x00' * buffer_len)
text_len = win32gui.SendMessage(hwnd, win32con.WM_GETTEXT, buffer_len, text)
text = win32gui.PyGetString(text.buffer_info()[0], buffer_len - 1).lower()
for match in self._windows[window_hwnd]['matches']:
if match["text"] in text:
self._windows[window_hwnd]['to_click'].append(match["button"])
if "button" in classname:
self._windows[window_hwnd]['buttons'].append({
'text': text,
'handle': hwnd,
})
return True
return callback
评论列表
文章目录