← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #179786]: Pass an argument to a sikuli script

 

Question #179786 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/179786

RaiMan posted a new comment:
********* corrected version of comment #1

--1. use of .skl
If you do not plan, to publish your scripts for others to download them or via e-mail, there is no need to save a script as executable (which is only a zipped version of the .sikuli). Just use the .sikuli as is.

--2. command line
Sikuli-IDE.bat -r "C:\Files\ScriptsWindows\Co-Branded_Uninstall.sikuli" --args "Fujitsu"

there are 2 hyphens needed with the --args option (so you might use your
own hyphened options). Every following string will go into the next
entry of the list (array) sys.argv beginning with index 1.

--3. script usage
sys.argv[0] usually contains the script name.
beginning with sys.argv[1] you have your parameters if any where given.

e.g. to check the parameter input:
parms = sys.argv[1:]
for i in range(len(parms)):
      print parms[i]
      # here you could do something
      # with the current entry

in your case with only one parameter:
if len(sys.argv) < 2:
    brand = "some default" # no parameter given
else
    brand = sys.argv[1]

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.