0

Why does grabwindow return black screen? Is a valid window and I do not receive any errors.

pix = QPixmap.grabWindow(hwnd)

And that way it works perfectly!

pix = QPixmap.grabWindow(QApplication.desktop().winId())

Below the complete source code:

def __init__(self):
    serverProtocol.RDCServerProtocol.__init__(self)
    self._array = QByteArray()
    self._buffer = QBuffer(self._array)
    self._buffer.open(QIODevice.WriteOnly)

def _makeFramebuffer(self, width, height):
    pix = QPixmap.grabWindow(197526) # Google Chrome Window
    pix = pix.scaled(width, height)
    if width >= self._maxWidth or height >= self._maxHeight:
        width = self._maxWidth
        height = self._maxHeight
    pix.save(self._buffer, 'jpeg')
    pixData = self._buffer.data()
    self._array.clear()
    self._buffer.close()
    return "%s" % pixData

I need to capture only the google window, but a black screen appears =/

Thank!

rodrigosillos
  • 67
  • 2
  • 10

0 Answers0