当前位置: 首页>>代码示例>>Python>>正文


Python mss.mss方法代码示例

本文整理汇总了Python中mss.mss方法的典型用法代码示例。如果您正苦于以下问题:Python mss.mss方法的具体用法?Python mss.mss怎么用?Python mss.mss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mss的用法示例。


在下文中一共展示了mss.mss方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def __init__(self, handle=None, dpifactor=1, **kwargs):
        super(Windows, self).__init__()
        self.app = None
        self.handle = int(handle) if handle else None
        # windows high dpi scale factor, no exact way to auto detect this value for a window
        # reference: https://msdn.microsoft.com/en-us/library/windows/desktop/mt843498(v=vs.85).aspx
        self._dpifactor = float(dpifactor)
        self._app = Application()
        self._top_window = None
        self._focus_rect = (0, 0, 0, 0)
        self.mouse = mouse
        self.keyboard = keyboard
        self._init_connect(handle, kwargs)

        self.screen = mss()
        self.monitor = self.screen.monitors[0]  # 双屏的时候,self.monitor为整个双屏
        self.main_monitor = self.screen.monitors[1]  # 双屏的时候,self.main_monitor为主屏 
开发者ID:AirtestProject,项目名称:Airtest,代码行数:19,代码来源:win.py

示例2: _region_to_image

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def _region_to_image(region) -> Image or ScreenshotError:
    # On Linux, try to use pyautogui to take screenshots, and revert to mss if it fails.
    # On Windows/Mac, do the reverse.
    try:
        if OSHelper.is_linux():
            try:
                grabbed_area = _pyautogui_screenshot(region)
            except ScreenshotError as e:
                logger.debug(e)
                grabbed_area = _mss_screenshot(region)
        else:
            try:
                grabbed_area = _mss_screenshot(region)
            except ScreenshotError as e:
                logger.debug(e)
                grabbed_area = _pyautogui_screenshot(region)
    except ScreenshotError as e:
        logger.error("Screenshot failed: %s" % e)
        raise ScreenshotError("Cannot create screenshot: %s" % e)
    return grabbed_area 
开发者ID:mozilla,项目名称:iris,代码行数:22,代码来源:screenshot_image.py

示例3: getmssimage

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def getmssimage(self):
        import mss
        
        with mss.mss() as sct:
            mon = sct.monitors[1]
            
            L = mon["left"] + self.X
            T = mon["top"] + self.Y
            W = L + self.width
            H = T + self.height
            bbox = (L,T,W,H)
            #print(bbox)
            sct_img = sct.grab(bbox)

            img_pil = Image.frombytes('RGB', sct_img.size, sct_img.bgra, 'raw', 'BGRX')
            img_np = np.array(img_pil)
            #finalimg = cv2.cvtColor(img_np, cv2.COLOR_RGB2GRAY)
            return img_np 
开发者ID:asingh33,项目名称:SupervisedChromeTrex,代码行数:20,代码来源:main.py

示例4: _mss_bugfix

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def _mss_bugfix(self):
        """Temporary windows DPI bugfix for mss"""

        os_ = platform.system().lower()
        if os_ == "windows":
            version = sys.getwindowsversion()[:2]
            if version >= (6, 3):
                # Windows 8.1+
                # Here 2 = PROCESS_PER_MONITOR_DPI_AWARE, which means:
                #     per monitor DPI aware. This app checks for the DPI when it is
                #     created and adjusts the scale factor whenever the DPI changes.
                #     These applications are not automatically scaled by the system.
                ctypes.windll.shcore.SetProcessDpiAwareness(2)
            elif (6, 0) <= version < (6, 3):
                # Windows Vista, 7, 8 and Server 2012
                ctypes.windll.user32.SetProcessDPIAware() 
开发者ID:SergeyKalutsky,项目名称:vsc,代码行数:18,代码来源:classifier.py

示例5: __init__

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def __init__(self, time_step, monitor):
        super().__init__()
        self.monitor = monitor
        self.time_step = time_step
        self.sct = mss.mss()
        self.last_execution_time = None
        self.begin_time = None

        y_offset, x_offset, size = self.get_minimap_bounds(
            self.sct.monitors[self.monitor]['width'],
            self.sct.monitors[self.monitor]['height'])

        self.minimap_bounds = {'top': y_offset + self.sct.monitors[self.monitor]['top'],
                               'left': x_offset + self.sct.monitors[self.monitor]['left'],
                               'width': size,
                               'height': size} 
开发者ID:andrewzwicky,项目名称:PUBGIS,代码行数:18,代码来源:live.py

示例6: __init__

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def __init__(self):
        self.root = tk.Tk()
        self.sct = mss.mss()

        self.root.title('Data Acquisition')
        self.root.geometry("660x325")
        self.root.resizable(False, False)

        # Init controller
        self.controller = XboxController()

         # Create GUI
        self.create_main_panel()

        # Timer
        self.rate = IDLE_SAMPLE_RATE
        self.sample_rate = SAMPLE_RATE
        self.idle_rate = IDLE_SAMPLE_RATE
        self.recording = False
        self.t = 0
        self.pause_timer = False
        self.on_timer()

        self.root.mainloop() 
开发者ID:kevinhughes27,项目名称:TensorKart,代码行数:26,代码来源:record.py

示例7: screenshot

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def screenshot(monitor, filename):
	log("Screenshot!")
	log(monitor)
	sct_img = mss.mss().grab(monitor)
	mss.tools.to_png(sct_img.rgb, sct_img.size, output=filename) 
开发者ID:pnprog,项目名称:goreviewpartner,代码行数:7,代码来源:toolbox.py

示例8: is_high_def_display

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def is_high_def_display():
        """Checks if the primary display is high definition."""
        main_display = MONITORS[0]
        screenshot = mss.mss().grab(main_display)
        if (
            screenshot.width > main_display["width"]
            or screenshot.height > main_display["height"]
        ):
            return True
        return False 
开发者ID:mozilla,项目名称:iris,代码行数:12,代码来源:os_helpers.py

示例9: get_display_factor

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def get_display_factor():
        main_display = MONITORS[0]
        screenshot = mss.mss().grab(main_display)
        display_factor = screenshot.width / screenshot.height
        return display_factor 
开发者ID:mozilla,项目名称:iris,代码行数:7,代码来源:os_helpers.py

示例10: _get_scale

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def _get_scale(screen_id):
    try:
        display = MONITORS[screen_id]
        display_width = display["width"]
        screenshot = mss.mss().grab(display)
        return screenshot.width / display_width
    except IndexError:
        return 1 
开发者ID:mozilla,项目名称:iris,代码行数:10,代码来源:display.py

示例11: __init__

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def __init__(self):
        self.landscape_template = cv2.imread(os.path.join('templates', 'dino_landscape.png'), 0)
        self.gameover_template = cv2.imread(os.path.join('templates', 'dino_gameover.png'), 0)

        self.shooter = mss()
        self.get_game_landscape_and_set_focus_or_die()
        self.reset_game()
        self.landscape = self.get_game_landscape_and_set_focus_or_die(.95)

        ground_height = 12
        self.y1 = self.landscape['height'] - 44
        self.y2 = self.landscape['height'] - ground_height
        self.x1 = 44 + 24
        self.x2 = self.landscape['width'] - 1 
开发者ID:pauloalves86,项目名称:go_dino,代码行数:16,代码来源:dino_api.py

示例12: screenshot

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def screenshot():
    with mss() as sct:
        sct.shot(mon=-1, output=file) 
开发者ID:Pure-L0G1C,项目名称:Loki,代码行数:5,代码来源:screen.py

示例13: send_image

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def send_image(self):
        with mss() as sct:

            while self.is_alive:

                # Capture the screen
                sct.shot(mon=-1, output=self.image)

                # Send screenshot
                for data in File.read(self.image):
                    self.recipient_session.sendall(data)

                # Send EOF code
                self.recipient_session.sendall(self.EOF)
                time.sleep(self.update) 
开发者ID:Pure-L0G1C,项目名称:Loki,代码行数:17,代码来源:sscreenshare.py

示例14: run

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def run():
    """
    Capture a screenshot

    """
    try:
	    with mss.mss() as screen:
	        img = screen.grab(screen.monitors[0])
	    data = util.png(img)
	    return base64.b64encode(data)
    except Exception as e:
        return "{} error: {}".format(run.__name__, str(e)) 
开发者ID:malwaredllc,项目名称:byob,代码行数:14,代码来源:screenshot.py

示例15: __init__

# 需要导入模块: import mss [as 别名]
# 或者: from mss import mss [as 别名]
def __init__(self, mss, monitor_info=None):
        self.mss = mss
        self.monitor = self.mss.monitors[monitor_info['monitor_num']]
        self.w, self.h = monitor_info["source_size"]
        self.top, self.left, self.right, self.bottom = monitor_info["crop"]
        self._mss_bugfix()
        self._update_monitor() 
开发者ID:SergeyKalutsky,项目名称:vsc,代码行数:9,代码来源:classifier.py


注:本文中的mss.mss方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。