Example #1
0
def get_ss_by_pyws(device_name, filename):
    # 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)
def get_ss_by_pyws(device_name, filename):
    # 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)
Example #3
0
 def getCapture(self):
     directory = 'capture'
     if not os.path.isdir(directory):
         os.makedirs(directory)
     try:
         handle = m.getid(self.windowTitle)
         rect = winxpgui.GetWindowRect(handle)
     except IndexError as e:
         self.setMessage(str(e))
         return
     cpimg = ImageGrab.grab(rect)
     cpimg = np.asarray(cpimg)
     cpimg = cv2.cvtColor(cpimg, cv2.COLOR_RGB2BGR)
     cv2.imwrite(
         directory + '/' + datetime.now().strftime("%Y%m%d%H%M%S") + '.jpg',
         cpimg)
Example #4
0
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# }}}
Example #5
0
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  # }}}