IDE Offset Button
If I press the Offset button I get some code like:
Region(
Where is .asOffset documented?
What is the Offset button for?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Mike
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Try this codes.
r1 = Region(
r1.highlight(2)
r2 = Region(
r2.highlight(2)
You can use "Offset" button when you want to create a region with offset.
This document will help you.
https:/
Revision history for this message
|
#2 |
I can get this to work:
r2 = Region(
However your code gave me:
[error] Error caused by: Traceback (most recent call last): File "C:\SX\
Did it run on your environment? I am Windows 10 Sikulix 1.1.4
I can imagine why you might want an offsetted region. However the button a) uses an undocumented method, and b) gives you no visual means of creating the offset.
It's still a bit of a mystery...
Revision history for this message
|
#3 |
Region.asOffset() is a not-documented-
anOffset = Region(
newRegion = someRegion.
I will remove the mystery by adding it to the docs ;-)
Revision history for this message
|
#4 |
BTW: the feature is intended to help in defining regions in a GUI relative to others, if a script should work independently of absolute positions on a screen.
You find one ore more fixed reference images and then the rest is relative to those by offsets.
Revision history for this message
|
#6 |
OK - I think I've got an idea of what this is. It actually produces a location that you can therefore feed in as an offset to a region. Right now it's not obvious what the sequence of events is but I can experiment.
Revision history for this message
|
#7 |
(Sorry - my response overlapped with yours )
Revision history for this message
|
#8 |
It looks to me as though no matter how you draw the rectangle, it will always produce a top-left to bottom-right offset, so for offsets that are to the left, or above the starting point, you are going to have go in and manually adjust one or both parameters. Prima facie, it will be wrong in 75% of cases.
Revision history for this message
|
#9 |
In fact, at time of first implementation, it was just a convenience tool, to measure distances between points.
Now that the result is visible as an Offset(x, y), I agree, that one expects the drawing direction (and hence the end point relative to the start point) should be taken into account.
Thanks for testing and pointing out.
Revision history for this message
|
#10 |
revised the implementation, so now the drawing direction is evaluated and shown with respective negative x and/or y.
Please test.
Revision history for this message
|
#11 |
Hi Raiman - completely different: was like:
Region(
now a simple:
Offset(156,93).
I tried a few permutations and it worked spot on (Windows 10 Sikulix vanilla install - no other Python and no environment settings).
For the record:
1) if no rectangle is selected then nothing is entered into the statement text (rather than eg Offset(0,0)
2) if you drag onto another screen the following is output:
Exception in thread "AWT-EventQueue-0" java.awt.
at sun.awt.
at java.awt.
at org.sikuli.
at org.sikuli.
at javax.swing.
at javax.swing.
at java.security.
at java.security.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at j
ava.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.security.
at java.security.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
[error] OverlayCaptureP
Many thanks - I think this will be very useful.
Revision history for this message
|
#12 |
Yes, both observations already materialised in my mind, while being busy with other things than SikuliX ;-)
Will check and repair asap.
Thanks.
Revision history for this message
|
#13 |
at 1: by intention (what other makes sense?)
at 2: I cannot test multi monitor situations currently. But I will setup a bug.
Could you please check, what happens, if you do that with the normal capture or the selectRegion button?
Revision history for this message
|
#14 |
If I start a region capture on Screen(0) and drag the mouse onto Screen(1) I get:
Exception in thread "AWT-EventQueue-0" java.awt.
at sun.awt.
at java.awt.
at org.sikuli.
at org.sikuli.
at javax.swing.
at javax.swing.
at java.security.
at java.security.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at j
ava.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.security.
at java.security.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
Exception in thread "AWT-EventQueue-0" java.awt.
at sun.awt.
at java.awt.
at org.sikuli.
at org.sikuli.
at javax.swing.
at javax.swing.
at java.security.
at java.security.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at j
ava.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.security.
at java.security.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
Exception in thread "AWT-EventQueue-0" java.awt.
at sun.awt.
eateWritableChi
at java.awt.
at org.sikuli.
at org.sikuli.
at javax.swing.
at javax.swing.
at java.security.
at java.security.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at java.awt.
at java.awt.
at java.awt.
nown Source)
at java.awt.
at java.awt.
at java.security.
at java.security.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
[error] OverlayCaptureP
If I start a take screenshot on Screen(0) and drag the mouse onto Screen(1) I get:
Exception in thread "AWT-EventQueue-0" java.awt.
at sun.awt.
at java.awt.
at org.sikuli.
at org.sikuli.
at javax.swing.
at javax.swing.
at java.security.
at java.security.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at j
ava.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.security.
at java.security.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
Exception in thread "AWT-EventQueue-0" java.awt.
at sun.awt.
at java.awt.image.Bu
fferedImage.
at org.sikuli.
at org.sikuli.
at javax.swing.
at javax.swing.
at java.security.
at java.security.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at javax.swing.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
[error] OverlayCaptureP
ce)
at java.awt.
at java.security.
at java.security.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
at java.awt.
With regard to 1): I agree
Revision history for this message
|
#15 |
thanks for testing.
please see related bug.