textshot icon indicating copy to clipboard operation
textshot copied to clipboard

Failed when have multiple monitors

Open KeyWgh opened this issue 4 years ago • 5 comments

image

Once I unplugged from external monitors it worked well. The problem is raised from line 29 in textshot.py, self.screen = QtWidgets.QApplication.screenAt(QtGui.QCursor.pos()).grabWindow(0)

My system is MacOS 10.15.3, with python 3.6.9. Thank you.

KeyWgh avatar Jun 14 '20 00:06 KeyWgh

I do not currently have the means to reproduce this, but I will try to fix it when I can. Seems strange, like an internal Qt error.

ianzhao05 avatar Jun 16 '20 04:06 ianzhao05

Also on multiple monitors, I am facing this behaviour where the text is selected from the other monitor. After adding pil_img.show() after line 84 in textshot.py, the scanned image spans across the two monitors. I am on macOS 11.3.1, python 3.8.5 and tesseract 4.1.1. The other packages were installed as per the requirements.txt.

As seen in the captured image, the scanned text comes from a PDF open on the second monitor.

Kapture 2021-05-05 at 15 34 38

Although this goes against the guidelines of a dark background and white text, I must also mention here that the app works fine when the Mirror Displays option is checked in the OS settings. Here are the generated images obtained through pil_img.show() used on the Preview tab in this window:

image Mirrored Display ON

image Mirrored Display OFF

hasantahir avatar May 05 '21 14:05 hasantahir

Thank you for the detailed information. In general, working with multiple monitors and grabbing the correct region is quite finicky. I believe it is OS dependent, and I don't currently have the setup to test/debug this.

ianzhao05 avatar May 08 '21 13:05 ianzhao05

To make it work for my dual monitor setup on Windows 10 (PyQt version 5.12.3), I had to set the geometry for the whole desktop (two screens side by side from left to right) instead of setting the window to fullscreen:

@@ -23,9 +21,10 @@ class Snipper(QtWidgets.QWidget):
         self.setWindowFlags(
             Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Dialog
         )
-        self.setWindowState(self.windowState() | Qt.WindowFullScreen)
-
-        self.screen = QtWidgets.QApplication.screenAt(QtGui.QCursor.pos()).grabWindow(0)
+        desktop_geometry = QtWidgets.QApplication.desktop().geometry()
+        self.setGeometry(desktop_geometry)
+        self.screen = QtWidgets.QApplication.screens()[0].grabWindow(
+            0, *desktop_geometry.getRect())
         palette = QtGui.QPalette()
         palette.setBrush(self.backgroundRole(), QtGui.QBrush(self.screen))
         self.setPalette(palette)

StefRe avatar Mar 22 '22 11:03 StefRe