Closed kkew3 closed 1 year ago
I just tried a simple script with only MSS, and no cursor is included. BTW the cursor is not included by default, you have to specifically ask for it using with_cursor=True
.
On my computer, without using pyautogui
, if I invoke the script via keyboard, once I type on the keyboard, e.g. typing "python ...", the mouse cursor disappears automatically, thus not included in mss
's screenshot. Therefore, the use of pyautogui
to force the appearance of mouse cursor is a must to reproduce the error.
I'm using a Mac, not GNU/Linux.
Oh, sorry I read too quickly the description.
Currently with_cursor
is only implemented on GNU/Linux. It seems that pyautogui is painting the cursor rather than moving it? And so it is part of the low-level image that MSS captures (simplified).
Anyway, as MSS on macOS doen't know yet how to include the cursor, the issue should be raised on the pyautogui repository I guess.
To see the cursor when you want to test, add a time.sleep(5)
before mss.shot()
so that you have time to move the cursor.
Thank you so much for your reply. I've found a workaround, which is to press Esc key, again using pyautogui
, immediately before invoking mss
, and the cursor is not included. Should I close the issue?
def get_now_screen(self):
monitor = {"top": 0, "left": 0, "width": 1075, "height": 900}
with mss.mss() as sct:
while True:
pyautogui.press('esc',2,interval=0.1)
now_screen = np.array(sct.grab(monitor))
# Put the captured screen in the queue
self.queue.put(now_screen)
How did you solve the problem? I tried pressing 'Esc,' but it didn't work. The mouse pointer also appeared in the screenshot
General information:
For GNU/Linux users:
Description of the warning/error
The screenshot includes a mouse cursor even if
with_cursor=False
.Open
x.png
and there will be a mouse cursor at coordinate (100, 100).Full message
No warning or error message.
Other details