How to set the screen of a new region

Asked by Glenn Tanner

When I create a region, i want to set the screen of that region. I can only find a getScreen option for the region https://sikulix-2014.readthedocs.io/en/latest/region.html#Region.getScreen. Just a moment ago i found vnc.newRegion() which creates a region with the screen defined, but if I want the screen to be screen(2) for the region I still do not see a way to accomplish that. For the sake of consistency, perhaps there is argument to be made that vnc.newRegion should be vnc.Region.

M = SUT['screen'].wait("Main_profile.png",g.waitDelay)
print M
R = Region(M.x, M.y, M.w, M.h)
print R
R2 = SUT['screen'].newRegion(M.x, M.y, M.w, M.h)
print R2

M[903,583 105x79]@S(VNC 13.1.18.55:5900) S:0.99 C:955,622 [723 msec]
R[903,583 105x79]@S(0)
R[903,583 105x79]@S(VNC 13.1.18.55:5900)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Glenn Tanner
Solved:
Last query:
Last reply:
Revision history for this message
Glenn Tanner (glenntanner3) said :
#1

After further reading. It seems newRegion needs to be added to the screen class globally.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

As far as I understand from your code snippet:

you have a match from a VNC-screen, that you want to use as Region on the local Screen(2).

If this is true, then try this:

R = M.copyTo(Screen(2))

Revision history for this message
Glenn Tanner (glenntanner3) said :
#3

It was more about quick values. I want to findText in a nearby region. I dont see where copyTo is documented.

R = Region(M.x-20, M.y+100, M.w+100, M.h+50) # need to be on VNC screen OR Screen(n) which is saved in SUT['screen'] = SCREEN || vncStart.
R.findText("some value")

so would this work?

R = Region(M.x-20, M.y+100, M.w+100, M.h+50)
R.copyTo(vncScreen) # case 1
R.copyTo(SCREEN) # case 2
R.copyTo(Screen(2)) # case 3

Revision history for this message
Glenn Tanner (glenntanner3) said :
#4

RESOLVED:

After searching for copyTo found "https://www.codota.com/code/java/classes/org.sikuli.script.Region" which showed the region is created with IScreen as the 5th param; however this is not in the main documentation.

R = Region(M.x, M.y, M.w, M.h, SUT['screen'])
R[903,583 105x79]@S(VNC 13.1.18.55:5900)

Revision history for this message
RaiMan (raimund-hocke) said :
#5

Interesting ;-) but not my effort.

It is true, that not all special features are documented. To see everything, that might be of interest, the javadocs might help.

There might be also some valuable hints here also for the VNC situation:
https://sikulix-2014.readthedocs.io/en/latest/screen.html#connecting-to-a-vnc-server-vncscreen

... and here are some helpers doc'ed also:
https://sikulix-2014.readthedocs.io/en/latest/region.html#extend-regions-and-create-new-regions-based-on-existing-regions

Revision history for this message
Glenn Tanner (glenntanner3) said :
#6

Understood, but i wouldn't call this special as multi screens are supported and "your" copy of documentation leaves out the 5th pram which is IScreen. If you could update the Region section to have included Region(x,y,w,h,[screen]) then this would have not been a question.

Revision history for this message
RaiMan (raimund-hocke) said :
#7

You are principally right.

... but though public, these methods are only for internal use.

You would not need these methods, if you use, what is documented as mentioned above.

And multi-screen is

The Screen class anyways is only a historical ghost monster, that would not be there if SikuliX would start today.

... sorry for the VNC implementation, which is in a state of some years ago (based on some contributions).
This currently is not my priority.

Revision history for this message
RaiMan (raimund-hocke) said :
#8

sorry, was interrupted and hit enter accidentally ;-)

And multi-screen is only defined for local screens.

Non-local screens are simply said a design and implementation accident ;-)

... and the Screen class will vanish anyways beginning with 2.1.0