How to invoke click() or wait() function by importing jar

Asked by Gin

Hi, I want to run my sikuli case in eclipse which supposed to be a jython script. And here's a piece of my script. When I imported the App class from org.sikuli.script in sikuli-java.jar, the App.open function worked well. But I have no idea that from which jar can I get the click() and wait() functions, seems they are not in the sikuli-java.jar. The code have errors of 'undefined variable click' and 'undefined variable wait'.

--------------------------------------------------------------------------------------------------

from org.sikuli.script import App
from org.sikuli.script import *

def login(exepath):
    App.open(exepath)
    wait("1384849271599.png", 300)
    click("1384849271599.png")

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Gin
Solved:
Last query:
Last reply:
Revision history for this message
Gin (opsmile) said :
#1

Em, I found the resolution by myself... wait() and click() function are defined in Region class, with is extended by Screen. So I can use them by following script:

--------------------------------------------------------------------------------------------------

from org.sikuli.script import Screen

s = Screen()
s.wait()
s.click()

...

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

How to use Sikuli with Jython in Eclipse is shown here

for RC3: http://doc.sikuli.org/faq/040-other-ide.html

for Version 1.0.1: https://github.com/RaiMan/SikuliX-API/wiki/Usage-in-Java-programming

To have the same possibilities as in the IDE, you have to use even in the main script
from sikuli import *

To activate all the convenience features of Sikuli for scripting (using un-dotted click to address the primary screen, import support, ...)

Your solution is simply replicating the Java level API in Jython. There are some differences between the Sikuli Jython API and the Java level API (mostly to be more convenient). So if you want to use Jython, you should stay with the Jython API as mentioned above.