Reputation: 8209
I'm taking a screenshot using this line
screen = QPixmap.grabWindow(QApplication.desktop().winId())
but apparently that doesn't grab the full desktop if the user has several monitors.
Is there a way to grab the desktop of all monitors into a single image?
Upvotes: 4
Views: 1279
Reputation: 88
Just need to loop over QApplication.screens()
and grab them one at a time like so...
Note: using Python 3.8 and PyQt5
import os
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
for screen in QApplication.screens():
screen_path = os.path.expanduser(f"~/Desktop/{screen.name()}.jpg")
screen.grabWindow(0).save(screen_path, 'jpg')
# grabWindow(0) means full screen
# for area use following format; x=0, y=0, w=-1, h=-1
Upvotes: 0