How to write sikuli script in a particular scenario

Asked by manas

Suppose I have written sikuli script having this logic
Ex1.sikuli
click(image1)
click(image2)
click(image3)
...
click(image n)
 and i have executed Ex1.sikuli
but next time when i will run same script instead of clicking on image 3 it will click on suppose some new image.and all other code will be same. Means i want to click on two image alternatively each time when i will run the same script.Is there any way to write this logic? I have written separate sikuli script to achieve this logic. But i want to merge two script into one.Please help

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
j (j-the-k) said :
#1

A very basic approach would be to pass the image-info as command line parameter:

script.sikuli

import sys
imageNumber = sys.argv[1]

if (imageNumber == 1):
  dynamicImage = imgX
else
  dynamicImage = imgY

click(img1)
click(img2)
click(dynamicImage)
...
click(imgN)

You can run it like this: Sikuli-ide.bat -r script.sikuli --args 1 or this Sikuli-ide.bat -r script.sikuli --args 2

However if there are multiple images that need to be exchanged, this approach will eventually become cumbersome.

Can you help with this problem?

Provide an answer of your own, or ask manas for more information if necessary.

To post a message you must log in.