How to action (edit. click) for matrix pictures (n column, m rows)

Asked by cuocdoi

Hi all,

 I've 200 pictures: 100 pictures lined up horizon, 100 pictures lined up vertically. All of them make a matrix.

pic11 pic12 pic13 --------- pic1100 // row 1
pic12 pic22 pic33 --------- pic3100 // row 2
...
...
.
.
.
.
pic1100 -----------------------pic100100 //row 100

My desired action were:

Right click pic11, pic12, pic13 ..... to pic1100 : end row 1
Then jump to row 2, and do action as row 1

How to do that? please help me.
Thanks,

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

If this is a regular matrix, that has an even row height and an even column width:

ref = find("some fixed visual element near pic11.png").targetOffset(x,y)
# targetOffset to be set with Preview to point to center of pic11

rowH = h # to be evaluated e.g. using Preview again
colW = w # to be evaluated e.g. using Preview again

pic11 = ref.getTarget() # center of first image

for col in range(100):
    for row in range(100):
        print "pic%d%d"%(row + 1, col +1)
        clickPoint = pic11.offset(col * colW, row * rowH)
        hover(clickPoint) # for test
        # rightClick(clickPoint)

BTW: the usual numbering would be
11 12 13 14 ..... 1100
21 22 23 24 ..... 2100
...
1001 1002 1003 1004 ... 100100

and to get distinguishable numbers in each cell:
001001 001002 ... 001100
..
001100 002100 ... 100100

Revision history for this message
cuocdoi (dientu15-12) said :
#2

Hi Raiman,

 I've some concerns and would your consult:

1.
       {code}
             ref = find("some fixed visual element near pic11.png").targetOffset(x,y)
       {/code}
         Can I remove "targetOffset(x,y)"? this entry is used for ?

a. Besides, how to know the parameter "x,y" in "targetOffset(x,y)" ?

b. And in case "x,y = 0,0 " will this value lead to click point is on the center of image.

c. Would you like to make ""some fixed visual element near pic11.png"" more clearly , please?

2.
    As in the document of Sikuli
"getTarget() : Get the location object that will be used as the click point."

but per on your script: [ pic11 = ref.getTarget() # center of first image> ] getTarget will get the center of picture11, do you type incorrect, maybe ? :)

Please correct for me if I'm wrong - I'm new user on Sikuli.

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

-at 1.
ref = find("some fixed visual element near pic11.png").targetOffset(x,y)

Sorry for bad code.
This is what I wanted to write:
ref = find(Pattern("some fixed visual element near pic11.png").targetOffset(x,y))

This happens:
- find will find the image "some fixed visual element near pic11.png"
- it creates a match object as ref, that has the information: when this is clicked, then use as click point a point with offset (x,y)
from the center of the match.

at 1a:
can be created by IDE Preview:
- capture the image
- click on the thumbnail
- on tab target offset you can do that

When back, hovering over the thumbnail will reveal, that it is now something like
Pattern("some fixed visual element near pic11.png").targetOffset(x,y)
and a little red cross is seen in the thumbnail now
(when using view -> menuShowThumbs (ctrl-t) toggles between image thumbs and real code (you might even change that and switch back again)

at 1b:
a targetOffset(0,0) will be the center of the match/image

at 1c:
pic11 = ref.getTarget() # center of first image

pic11 now is a point somewhere inside pic11, since ref.getTarget() returns the point, that is defined by setting the offset before with preview in the Pattern.

Now that the code is correct, you can just try a little example, e.g. on this page here:

ref = find("sikuli logo in the upper left corner.png).targetOffset(x,y)

with Preview just set the offset so that it points to the menu entry <Bugs>

menuBugs = ref.getTarget()
click(menuBugs)
wait(5) # just to see what happens

the bugs page should open.

Revision history for this message
cuocdoi (dientu15-12) said :
#4

Thanks RaiMan, that solved my question.