def OnInitDialog(self, hwnd, msg, wparam, lparam): self.hwnd = hwnd # centre the dialog desktop = win32gui.GetDesktopWindow() l, t, r, b = win32gui.GetWindowRect(self.hwnd) dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop) centre_x, centre_y = win32gui.ClientToScreen(desktop, ((dt_r - dt_l) // 2, (dt_b - dt_t) // 2)) win32gui.MoveWindow(hwnd, centre_x - (r // 2), centre_y - (b // 2), r - l, b - t, 0) # self._SetupList() l, t, r, b = win32gui.GetClientRect(self.hwnd) self._DoSize(r - l, b - t, 1)
def get_screenshot(device_path, device_name, filename): # {{{ if device_path != "": screencap_cmd = ["adb", "shell", "screencap", device_path] subprocess.check_call(screencap_cmd, shell=True) pull_cmd = ["adb", "pull", device_path] subprocess.check_call(pull_cmd, shell=True) else: # get window handle hwnd = m.getid(device_name) # get window position rect = winxpgui.GetWindowRect(hwnd) # get window size size = winxpgui.GetClientRect(hwnd) # make list [x, y, w, h] cap = [rect[0], rect[1], size[2] + rect[0], size[3] + rect[1]] # capture img = ImageGrab.grab(cap) # save img.save(filename) return # }}}