Easiest way to convert sikuli code to java?

Asked by Jeff Sant

Guys,

Is there any easiest way to convert Sikuli code in java?

I have read this from documentation blueprints, i am not sure if this works or not.

https://blueprints.launchpad.net/sikuli/+spec/sikuli-export-to-java-code

Your help would be appreciated.

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

No, not yet available.

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

--- blueprint:

the suggested approach has not been tested until now.

So be the first ;-)

Revision history for this message
Jeff Sant (sant-jeff) said :
#3

I tried to do this, but got following error.

java -cp sikuli-script.jar org.python.util.jython test.sikuli\test.py
Traceback (most recent call last):
  File "test.sikuli\test.py", line 81, in <module>
    if exists("test1.png",180):
NameError: name 'exists' is not defined

all the class path and .py file path are correct.

Any suggestions why it does not recognize exists?

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

you need an
from sikuli.Sikuli import *

in the first lien of your script, in all cases when you use a Jython interpreter to run the contained .py directly.

furthermore your script does not know where your images live in this case. You have to set the image path yourself.

What is your intention doing this? There are only disadvantages against the run as
java -jar sikuli-script.jar test.sikuli

The version you are trying makes only sense, if you need to do some things, before Sikuli is initialized.

Revision history for this message
Jeff Sant (sant-jeff) said :
#5

actually i want it to be a java program so i need not to install sikuli on each pc i want to use my program.

where should i define the images path?

Revision history for this message
Jeff Sant (sant-jeff) said :
#6

java -cp sikuli-script.jar org.python.util.jython test.sikuli\test.py
[info] Sikuli vision engine loaded.
[info] Windows utilities loaded.
[info] VDictProxy loaded.
[info] Text Recognizer inited.

i got this results and prompt back, but can not find any class in the test.sikuli folder, any idea?

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

-- 1. want it to be a java program so i need not to install sikuli on each pc
that is not possible currently. You need at least sikuli-script.jar and the libs directory with it's content on each machine together with the correct system path settings.

--2. can not find any class in the test.sikuli folder
I just tried on Windows: you are right. So forget this solution. I will purge it from the docs.

Have a look at the Java class ScriptRunner (http://sikuli.org/doc/java-x/org/sikuli/script/ScriptRunner.html), which is internally used to run the scripts. I know, that some people are using this approach, to wrap running Sikuli scripts into there Java code. You might have to look into the Sikuli sources to find out, how it works.

Revision history for this message
Jeff Sant (sant-jeff) said :
#8

any update of this in new version which will be released on 15th sept?

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

no

Can you help with this problem?

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

To post a message you must log in.