Search code examples
jythonsikulisikuli-script

Typecast int variables to strings in Jython for use in Sikuli


I want define a path using the looping variable like this:

for i in range(2,4):
    click("1480530304554.png")
    wait("1480531095180.png")   
    type("cd D:\ISB\Pairs\" + str(i) + "\Acq\" + Key.ENTER)

This typecasting does not work in Sikuli which supports jython. Error is:

SyntaxError ( "no viable alternative at input 'cq'", )

Whats the way around this?


Solution

  • In Windows systems, to define a path you must use double backslash. This will do what you need:

    type("cd D:\\ISB\\Pairs\\" + str(i) + "\\Acq\\" + Key.ENTER)