def attach(self, device):
if self.device is not None:
print "Warning: already attached to a device."
if device is not self.device:
self.detach()
handle = device.hwnd
def callback(hwnd, extra):
extra.add(hwnd)
return True
self.watched_hwnds.add(handle)
try:
# EnumChildWindows may crash for windows have no any child.
# refs: https://mail.python.org/pipermail/python-win32/2005-March/003042.html
win32gui.EnumChildWindows(handle, callback, self.watched_hwnds)
except pywintypes.error:
pass
self.device = device
print "attach to device", device
评论列表
文章目录