An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
Questions tagged [python-mss]
77 questions
7
votes
1 answer
Is there a way to take screen shots of desktop that not current active one using mss?
I'm trying to record screen when playing a website by using mss and opencv, but I don't want the program to use the current screen. I want to put them to play on a second desktop, like Desktop 2 in the following picture
macos have 4 desktop setup
so…

News Good
- 83
- 2
4
votes
0 answers
Getting black or white image when calling mss screenshot function second time
I used mss module (https://pypi.org/project/mss/) to make screenshots. When calling function second time, I get black or white image. The weirdest thing is that ocasionally it succeeds.
I tried giving some time like sleep(1) between calls but it…

Jakub Bielan
- 575
- 1
- 5
- 14
4
votes
2 answers
Can't record screen using mss and cv2
I have the following code
from mss import mss
import cv2
import numpy
class MSSSource:
def __init__(self):
self.sct = mss()
def frame(self):
monitor = {'top': 0, 'left': 0, 'width': 640, 'height': 480}
grab =…

guest-418
- 1,574
- 1
- 13
- 19
4
votes
1 answer
mss sct.grab won't let me select which monitor to use
I have two monitors connected to my computer with both active at the same time. The monitors are not mirrored - each displays different content.
I need to be able to select in code which of these two monitors I want to use with sct.grab.
I have…

Bob Finley
- 41
- 1
- 2
3
votes
1 answer
How to fix KeyError: 'DISPLAY' in Python
I am using mss library in Python to take a screenshot and save it on the current path. It is working perfectly on my Mac using PyCharm. But when I try to run the same thing on Ubuntu 16 I get an error, even when I am doing exactly as the Docs…

Lucas123
- 61
- 1
- 1
- 5
3
votes
1 answer
Pytesseract, trying to detect text from on screen
I'm using MSS in conjunction with pytesseract to try and read on-screen to determine a string of characters from the region being monitored. My code is as follows:
import Image
import pytesseract
import cv2
import os
import mss
import numpy as…

Justin
- 125
- 1
- 2
- 12
2
votes
0 answers
Python: Tkinter + MSS = mss.exception.ScreenShotError: XDefaultRootWindow() failed
I am facing a pretty strange behavior of Python MSS library when using inside Tkinter GUI.
I have a Tkinter window that has a button for popping up a TopLevel window. Inside that TopLevel window, I have a button for taking a screenshot (using MSS).…

41v4
- 21
- 1
- 3
2
votes
1 answer
Python MSS Screen Capture target specific windows
Is there any way to screencapture specific windows from windows handle? Even the windows is in the background it still will capture it. currently i only have this code for record the fullscreen desktop not in the specific windows.
def…

whyeyes
- 21
- 1
- 2
2
votes
1 answer
how to capture the mouse pointer in screenshot
I use the python-mss to capture the screenshot and use these screenshot with opencv to generate a video recording. As I want to capture the mouse movement in the video.
But it seems that the mouse pointer can not be captured in snapshot. How can I…

ldw2020
- 23
- 3
2
votes
0 answers
Is there anyway to take a screenshot with maximum PPI?
I'm trying to take screenshot on my Mac and for I need to pass the screenshot to pytesseract, I'd like to know if there is anyway for grabbing a region of the screen at the maximum PPI.
I noticed that it's always 72 DPI, is there anyway to take it…

X1foideo
- 46
- 5
2
votes
2 answers
XGetImage Failed Error when using python MSS library on Ubuntu
I'm encountering an error when using mss, on Ubuntu 18.10 (if that matters). Here's my code (Taken from their examples in the documentation, plus some extra error output):
import mss
with mss.mss() as sct:
try:
filename =…

DoYouEvenCodeBro
- 391
- 3
- 14
2
votes
2 answers
Accelerating a screenshot function - Python
I need my screenshot function to be as fast as possible, and now every call to the function takes about 0.2sec.
This is the function:
def get_screenshot(self, width, height):
image = self.screen_capture.grab(self.monitor)
image =…

Adi Koch
- 91
- 9
2
votes
1 answer
How does one find a pixels location from image.pixel?
So, i have this script which works, it prints out all the pixels that have and rgb value of (102,102,102) but i don't know how I would be able to now get that pixels location and click it.. any suggestions?
edit: by pixels location i mean the…

Jake Sanford
- 47
- 5
2
votes
1 answer
How to I make my python program take screenshots faster?
I have been working on this script that clicks the wherever the pixel of a certain color is on the screen, but i ran into a problem, when i loop this it takes screenshots, but only about 12 during a 30 second loop when it SHOULD be taking 600 for…

Jake Sanford
- 47
- 5
2
votes
1 answer
Fastest screenshot library python/improve performance of mss package
python 3.6, Windows 10:
I am trying to take one (partial) screenshot every 1-5 milliseconds to then run some custom OCR on it to extract some data.
My code for taking the screenshots using the mss package takes between 16 and 47ms depending upon…

user2136502
- 69
- 1
- 3