← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #682295]: [1.1.4] macOS 10.14.5 - Taking a screenshot with SikuliIDE on an external monitor with a Retina primary display

 

Question #682295 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/682295

Jeff Harmon posted a new comment:
I have a similar issue to the original reporter, though my primary
display is the external monitor.

I have a Retina MacbookPro connected to an external display.  The
external display has a resolution of 2560x1440 but is not treated as
Retina by MacOS (Big Sur).  I have the dock on the external display,
which for Sikuli I believe means it is Screen 0.  Sikuli sees Screen 1
as the native screen of the MacBook Pro (Retina) positioned to the left
through Display configuration.  Here is Screen.showMonitors() from Java
using Sikuli API:

*** monitor configuration [ 2 Screen(s)] ***
*** Primary is Screen 0
Screen 0: R[0,0 2560x1440]@S(0)
Screen 1: R[-1680,284 1680x1050]@S(1)
*** end monitor configuration ***

With the configuration this way, I can reliably find images on Screen 0,
but the pixel dimensions are so far off on Screen 1 (the Retina screen)
I can't reliably do finds.  Sikuli API doesn't seem to be capturing
things correctly on the Retina screen in this configuration.

See https://github.com/harmonjeff/sikuli-retina-
bug/tree/master/FailedCaptureImages

To illustrate the issue I created a test Java application that uses the
Sikuli API to capture the screens.  I opened up two windows of TextEdit,
placing one on each screen.  I sized the TextEdit window to cover the
entire screen (except the dock on Screen 0).  You can see the source
here:

https://github.com/harmonjeff/sikuli-retina-bug

In researching what could be going on I discovered a system property
that seems to make things function correctly as far as Siklui API
capturing and finding images using Java.  If I set the
"sun.java2d.uiScale" property to be "1.0" then the captures in the
sample application function correctly.

https://github.com/harmonjeff/sikuli-retina-
bug/tree/master/SuccessCaptureImages

This solution works for me with everything except that my use case for
Sikuli API is to drive an application using reference images I capture
using Siklui beforehand.  Images captured using Siklui on the Retina
display do not match well when the application is on the non-Retina
screen and vice-versa. I can capture the reference images to be used by
the UI automated testing from both but I need to detect if the
application is on the Retina screen or the non-Retina screen to know
which reference images to use.

The best way I have seen to detect if an application window is on a
Retina screen in Java 9+ is in the same code, the isRetina method.  The
method only works if the system property is not defined.  I don't have a
way to both detect the application is running in a Retina screen and
have the capture/find Sikuli API functions work properly.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.