[HowTo] use Sikuli from Ruby - JRuby needed

Asked by Yashwanth N

Hi, I am able to use sikuli methods in python. But no idea about using in ruby. My professor told me to use ruby instead of python. So, can some1 could help me out with this. Small code snippet or steps would be appreciated.
If i want to use below python code in ruby, what all changes i have to make?

from sikuli.Sikuli import *
from sikuliwrapper import *

class abc(object):
        def _init_(self):
                self.appCoordinates = (0,0,1024,768)

      def action(self, *args):
               find("abc.png")
               click("select.png")

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:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

For Python language Sikuli has a built-in scripting support (supported by the Sikuli IDE and running scripts from command line) for Python language level 2.5, which internally is handled by the bundled Jython interpreter (Java based).

Besides that, you can use the features based on sikuli-script.jar with every Java based scripting/programming:
native Java, Scala, Clojure, Groovy, JRuby, ...

by simply having a standard Sikuli installation and importing the Sikuli stuff having sikuli-script.jar in the Java class path.

So if we are talking about Ruby language, you have to run your scripts using the JRuby interpreter and observe some specifics based on the fact, that we are running in a Java environment.

The big advantage of JRuby over Jython is the possibility, to add/change features to/of the Sikuli base.
But you have to step down to the Java level of the Sikuli API and you need some basic Java knowledge.
(http://doc.sikuli.org/faq/030-java-dev.html)

Revision history for this message
Yashwanth N (yashthekool2009) said :
#2

@RaiMan,

Thank you sir. I will talk with my professor about this. If he wants in ruby only, i will try with Jruby otherwise will continue in python. If i get some doubts in Java level of sikuli API, can i get back to you?

Thanks,

Revision history for this message
Yashwanth N (yashthekool2009) said :
#3

Thanks RaiMan, that solved my question.

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

Always welcome