Portable Sikuli Scripts?

Asked by Vaibhav thakur

I am here again asking for help. I really love the support out here. So I was wondering if I take the sikuli scripts with me where ever we go? Do we really need sikuli IDE and java Jdk to run Sikuli scripts? and is there any way like we can extract the needed components to their respective places. Cause I was thinking to make a visual basic application, that'll open different sikuli scripts by different commands. It will be convenient to launch sikuli scripts with portability so that we don't have to Install sikuli IDE, then Java Jdk and then run it.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Calle Rundgren (c-rundgren) said :
#1

From what I learned from this page in the sikuli documention
http://sikuli.org/docx/devs/system-design.html#sikuli-ide

The sikuli IDE must be installed since sikuli the sikuli IDE still runs in the background even though a sikuli executable file has been exported.

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#2

But is it necessary that Sikuli IDE must be installed? if it's not there might be some way to use it, by using some installer or extracting?

Revision history for this message
Calle Rundgren (c-rundgren) said :
#3

Yes, the sikuli IDE has to be installed since it is teh IDE who executes the scripts.

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#4

So It Cannot Be done in anyway? If we have to use Sikuli in other Pc, He has to download Sikuli IDE, Java and my .skl . to run the vb file?

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

What Calle mentioned is principally right: If you assure, that Sikuli-IDE and it's prereqs are running on the target machine, you are on the safe side.

But if you look from the side, what is at least needed, to run a script (in the form as .sikuli, which is an unzipped version of a .skl), then it is sikuli-script.jar and the libs folder of the IDE's installation directory. Then you can run your script using a java command (see: http://sikuli.org/docx/faq/010-command-line.html#running-sikuli-script-jar-from-command-line). But this is still some 10 or more MB's, that has to be brought somehow to the target machine.

If you know how to program in Java, it is possible rather easy, to build a self contained mySikuliScript.jar, that contains everything needed to run scripts on another machine just with a java command, installs itself and runs the scripts as needed. Have a look at the extensions concept to get a feeling what might be possible in the future.

And do not forget, that Sikuli scripts are able to load their images from the web, which reduces a script to it's .py file, which might be easier to handle when distributing a script, than a complete .sikuli folder.

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#6

Thank you RaiMan, Once again :D
I used the Sikuli-script.jar command, It works like a charm.
It makes the application much portable. As I don't know Java coding, I cannot build the installer in Java. But I used a application called "NSIS" It makes the installer. While Using Run a script without IDE command, All it needs is the myscript.sikuli file + Libs Folder + Sikuli-script.jar?

And about the .py file, you said, it load the images from the web?
So do i have to edit the .py file?
"click("image.png")"
So I have to replace it with the web link?
"click("mywebsite.com/image.png"

Also Can It also read the script from the py file, So I can update the script remotely? Something like, making the sikuli to read the script from web, which can enable us to update it regularly?

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

--- NSIS
Thanks for the tip, I will have a look at it. seems very capable.

-- All it needs is the myscript.sikuli file + Libs Folder + Sikuli-script.jar?
Yes, but the target machine also needs the pointer to the folder containing the Libs folder and path-to-java/jre6/bin in system path, when running a script.

-- load the images from the web?
you have to simply put a reference url, where your images are stored into the image path:
read the section containing this link: http://sikuli.org/docx/globals.html#addImagePath

I just realized, that the web access for images is not mentioned there: just use a complete valid folder url as path to add.

-- Can It also read the script from the py file?
Of course you ca do that. You either use a command like wget on unix systems (issue commands with subprocess.Popen()), to download the file, or use the respective Python internet access modules to do the same. with shutil.move() you can replace the .py, so it will be the new the next time (It is not possible to reload the script during the run that updates it :-(

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#8

--- NSIS
**Your welcome, Glad I could be useful to you in anyways :D

"Yes, but the target machine also needs the pointer to the folder containing the Libs folder and path-to-java/jre6/bin in system path, when running a script."
** I have the pointer (the batch file), So are there any softwares which set the path of Java? Doesn't the Java installer It self points to the bin?

-- load the images from the web?
Thank you, I'll try it. :D

-- Can It also read the script from the py file?
Is there anyway in windows os? Hmm python, as I am not a python programer I can't do that. I will exprement with different stuff and see what I can get. So All we need to update the .py and the images to fully update the script? Am I Right? Thank you so much again.

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

--- need to have 1.) path to Libs folder and 2.) path-to-java\jre6\bin in system path (%PATH%)
1.) is needed for the .ddl's to find each other
2.) Java installer does not populate system path. the java command is in the system32 folder, that is in path as standard. the rest is managed by java itself internally and via environment variables at runtime.
Both entries are currently needed (Sikuli IDE installer does it for you). So you either put this in system path via the registry or the settings or you put it in your cmd/bat, that allows a user to run your scripts.

-- Can It also read the script from the py file?
* for wget a starting point: http://gnuwin32.sourceforge.net/packages/wget.htm
* yes it is the script file .py and the referenced image files (if you want them locally) (the .html is a gimmic, that is created when saving a script in the IDE, to show the script with it's image thumbnails in a browser - never needed it ;-)

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#10

Okay I'll try doing that. i didn't find help making a path to jr6 folder.
I tried extracting the registry using UniExtract but I failed. I tried making running the sikuli script on the target machine without the Java Path, it didn't worked, though I knew the results, i was just experimenting. if you have any registry files, that make the path to Java bin please help me thanks :)
--Wget is awesome. I downloaded it's gui version to generate batch file, with my server with .py file

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

--- path-path-to-java/jre6/bin
to just test it, I think it is sufficient to put it in the batch file that runs your script.

To make it permanent, you have to go to system settings -> extended settings -> environment variables and adjust the path entry. So I guess, this has an entry in the registry in the background (do not know which one)

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#12

Thanks RaiMan, that solved my question.

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#13

Hello, Sorry for disturbing. But I couldn't get it to work.
I got my path to libs folder, set the path to bin's folder.
But I'am Still getting a error. After Asking on different forums, I had to come to disturb you again. :(

So My batch file has the following code.
PATH=%PATH%;"C:\Program Files\Java\jre6\bin"
java -Djava.library.path="C:\test1\Data\libs" -jar sikuli-script.jar foo
java -jar Data\sikuli-script.jar Data\MySikuliScript.sikuli

And it gives me
C:\test1\test1>PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\P
rogram Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
 Server\100\DTS\Binn\;E:\Program Files\Universal Extractor;E:\Program Files\Univ
ersal Extractor\bin;C:\Program Files\Java\jdk1.6.0_21\;C:\Program Files\OpenVPN\
bin;C:\Program Files\Sikuli X\libs;C:\Program Files\Java\jre6\\bin;C:\Program Fi
les\proXPN\bin;"C:\Program Files\Java\jre6\bin"

C:\test1\test1>java -Djava.library.path="C:\test1\Data\libs" -jar sikuli-script.
jar foo
Unable to access jarfile sikuli-script.jar

Thank you again :)

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

to simulate the situation on another machine, where Sikuli is not installed, I suggest as an example the following setup:

-- we have a directory
c:\sikuli
where the following is stored (the full path in this example):
sikuli-script.jar ( c:\sikuli\sikuli-script.jar )
the libs directory from the Sikuli installation ( c:\sikuli\libs )

this directory is needed on the target machine.

- and we have a directory:
c:\sikuli-scripts
where we store the test scripts as .sikuli folders
a test script: c:\sikuli-scripts\test.sikuli

- this is the command sequence to run a script in this scenario:
PATH=%PATH%;c:\sikuli\libs;c:\Program Files\Java\jre6\bin
java -jar c:\sikuli\sikuli-script.jar c:\sikuli-scripts\test.sikuli

- comment:
PATH=%PATH%;c:\sikuli\libs;c:\Program Files\Java\jre6\bin
this is only needed, if it is not already in system path using system settings -> extended settings -> environment variables.

Revision history for this message
Vaibhav thakur (xorebbecaxo) said :
#15

Thanks RaiMan, that solved my question.