selecting the next image in line

Asked by Justin May

I am pretty new to SIKULI, so this issue might be pretty easy to figure out, I hope.

I am having an issue with getting my script to correctly select the next image on the screen. I have a series of graphics in a Illustrator document and I want SIKULI to cycle thru and select each one in order from left to right and give each one a unique file name. The file naming is not an issue just the image selection. My code is below. Thank You.

x=0
percent=00.0
image=Pattern("01-2.png").exact()

while x <1000:
    print
    switchApp("Adobe Illustrator.app")
    type("v")

<!--This while loop is the problem area-->
while x <1000:
        image=right(5)
        click(image)
        break

    click("Edit-1.png")
    click("Cut.png")
    click("1339077451192.png")
    click("File.png")
    click("New.png")
    click("OK-1.png")
    click("Edit.png")
    click("Paste.png")
    click("OK-2.png")
    type("\r")
    click("File-1.png")
    click("SaveAs-1.png")

    while x < 1000:

        percent+=.1
        paste(str(percent))
        x+=1
        break

    click("Save-1.png")
    click("OK.png")

Question information

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

I understand, that there are some images in a row with some regular distribution and size (thumbnails ?).
You want to click on each one and do some action.

If this is true, the you have to
- position on the first image somehow
- in a loop:
  - do your actions
  - position on the next image somehow

e.g. supposing you have
- 10 images
- each image is width 100
- the distance between 2 images is 20

firstImage = find("something.png")
nextImage = firstImage
for i in range(10):
    click(nextImage)
    # your actions
    nextImage = nextImage.offset(Location(120,0))

hope it helps ;-)

Revision history for this message
Justin May (may-justin01) said :
#2

Found the answer!

x=0
percent=00.0
findcoord=hover(Pattern("00-1.png").exact())
findcoord=Env.getMouseLocation()

while x <1000:
    print
    switchApp("Adobe Illustrator.app")
    type("v")

while x <1000:
        findcoord=findcoord.right(72)
        click(findcoord)
        break

    click("Edit-1.png")
    click("Cut.png")
    click("1339077451192.png")
    click("File.png")
    click("New.png")
    click("OK-1.png")
    click("Edit.png")
    click("Paste.png")
    click("OK-2.png")
    type("\r")
    click("File-1.png")
    click("SaveAs-1.png")

    while x < 1000:

        percent+=.1
        paste(str(percent))
        x+=1
        break

    click("Save-1.png")
    click("OK.png")