iseahound / Vis2

Simple OCR using Tesseract
158 stars 33 forks source link

Support for multi monitor #17

Closed thdoan closed 2 years ago

thdoan commented 2 years ago

I have a two-monitor setup where my external monitor is my primary display and my laptop screen (1920x1080) is my secondary display. I used WindowSpy.ahk to identify the coordinates on my laptop screen, but the OCR does not appear to work with negative coorindates, e.g.: OCR([-1849, 362, 64, 17]).

Is there a way to OCR a region from a secondary display?

iseahound commented 2 years ago

Vis2 already works with multi monitor capture. Please try using:

ImagePutWindow([-1849, 362, 64, 17])

before using OCR to diagnose your issue. If the problem persists, you may update the version of ImagePut from v1.6 to v1.8.1 here: https://github.com/iseahound/ImagePut (but my testing showed that it worked with v1.6 fine)

thdoan commented 2 years ago

@iseahound thanks for the quick reply -- I confirmed that it worked :). It seems the coordinates displayed by WindowSpy.ahk is not 100% reliable since it can provide wrong numbers if the DPI of primary and secondary displays are different.

There is one more thing that I can't resolve: how do I get Subtitle.Render() to display on the secondary display instead of the primary display? I tried Render("Testing", "x-100") and the text is shifted to the left correctly but nothing shows up on the secondary display.

iseahound commented 2 years ago

I suggest you use TextRender which is a modern rewrite of Subtitle. The syntax is largely the same.

https://github.com/iseahound/TextRender

thdoan commented 2 years ago

@iseahound I was able to use TextRender().Default() to display the text on primary monitor, then drag it to the secondary monitor. Curious, is there a way to initialize the text so it displays on the secondary monitor without dragging? I tried x:-1000 but the text is not displayed on the secondary monitor (virtually positioned to the left of primary monitor).

iseahound commented 2 years ago

If you download the zip and run Showcase 03, it should display on your extended monitor.

https://github.com/iseahound/TextRender/releases/tag/v1.8

Your syntax of x:-1000 is correct.

thdoan commented 2 years ago

@iseahound I just tried Showcase 03 and the text was not displayed on the secondary laptop screen:

https://youtu.be/dU7F3yo14l4

Here's my display settings, set to "extend these displays" where 1 is secondary (laptop) and 2 is primary: image

iseahound commented 2 years ago

I believe a bugfix was just pushed out, please try the latest version and confirm your screen coordinates.

https://github.com/iseahound/TextRender/blob/main/TextRender%20(for%20v1).ahk

Notably in Showcase 03, since your y coordinate of 0 is cut off it will not be visible. Changing y:"Top" to y:540 should display it. (That should probably be the default behavior, hmmm...)

image

thdoan commented 2 years ago

I found out I was already using v1.8.0. After changing to y:540 I could see the text going from secondary (left) to primary (right). Thanks, I will study the script and go from there.