Passing multiple text arguments into Sikuli.

Asked by bigtom

I would like to pass a number of text strings into Sikuli. I need a number of strings for completing a web form. I am not really finding any information on doing this. I did find that I can run a script from the command line with arguments, but there is no information on what the arguments do or how they are handled.

I can save the text to various txt files and maybe use those as the source.

I am hoping for some guidance to documentation on this or some help to understand how this can work.

Running OSX

Thanks

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
RaiMan (raimund-hocke) said :
#1

At least for version 1.0.1 this works already for the IDE:

- in the start-up splash screen you can enter in the parameter field:

-- test1 test2 test3

and in the IDE at script run the sys.argv contains the 3 strings beginning at 1

e.g.
for e in sys.argv[1:]: print e

will print
test1
test2
test3

Be aware: if a parameter string contains blanks, you currently have to mask them with an otherwise unused character, that you replace before using the parameter, because the parameter handling uses space as delimiter.
This will be easier in version 1.1

e.g. parameters
test#me#now test2

will give with
for e in sys.argv[1:]: print e.replace("#", " ")

test me now
test2

using from command line:

runIDE -r some_script.sikuli -- test1 test2

Revision history for this message
bigtom (toathoudt) said :
#2

Should I use the type or print function to fill the text fields?

ie. with the third argument being a3:

sys.argv[1:]: type a3.replace("#"," ")

If i need returns in the entry I am guessing I will need to break each paragraph into separate arguments and press the return key in between them.

The documentation on the functions and their usage can be found in which base language?

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

ok, Sikuli script talks Python.

the above example was only, to check wether this works for you printing the contents to the message area.

To use the values, you have to assign them to variables or a list, that you the use with type.

e.g.
to get all supplied vars in a list and use them with type afterwards.

vars = [] # empty list
for e in sys.argv[1:]:
    vars.append( e.replace("#", " ") )

type(vars[3])
type(Key.ENTER)

Can you help with this problem?

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

To post a message you must log in.