How to pass in parameters to a sikuli script?

Asked by milin agrawal

hiii

I would like to know if there is a way to pass in parameters for a Sikuli script?
its my script,n i want to enter different url's at the different time.

switchApp("C:\Program Files\Internet Explorer\iexplore.exe")
find(image )
click(image )
type( 'http://yahoo.com' )
click(image )

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

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

look: http://sikuli.org/docx/faq/010-command-line.html

In your script the parameters are available in sys.argv[], where element 0 contains the scriptname and the parameters are in elements 1 upwards.

Revision history for this message
milin agrawal (milin) said :
#2

i am unable to do any thing plz provide me code for the script

Revision history for this message
milin agrawal (milin) said :
#3

switchApp("C:\Program Files\Internet Explorer\iexplore.exe")
find(image )
click(image )
type( 'http://yahoo.com' )
click(image )

what changes required in this code

Revision history for this message
milin agrawal (milin) said :
#4

by mistakelly i click on solve problem button,plz ignore it and let me know the code

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

Sorry, but if you want to use more advanced features, you have to learn how to use some needed Python features ;-)

So here you are, to motivate you a little bit:

--- running script from commandline with a parameter:

You should be in the directory containing your script.sikuli

PATH-TO-SIKULI/sikuli-ide.bat -r script.sikuli --args "yahoo.com"

--- inside your script:

switchApp("C:\Program Files\Internet Explorer\iexplore.exe")
find(image )
click(image )
type( 'http://' + sys.argv[0] )
click(image )

comment: I found that in the current version the given parameters are in sys.argv[0] upwards

Can you help with this problem?

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

To post a message you must log in.