Reputation: 1040
I've just installed SikuliX(sikulixapi-2.0.4.jar) and Eclipse Oxygen under Ubuntu 16.04. The testing program is the following :
import org.sikuli.script.*;
public class Test {
public static void main(String[] args) {
Screen s = new Screen();
try{
s.click("imgs/spotlight.png");
//s.wait("imgs/spotlight-input.png");
//s.click();
s.write("hello world#ENTER.");
}
catch(FindFailed e){
e.printStackTrace();
}
}
}
However, when I run the testing program I receive the error message below :
[error] ImagePath: find: not there: imgs/spotlight.png
FindFailed: imgs/spotlight.png: (0x0) in R[0,0 1280x800]@S(0) Line 2222, in file Region.java at org.sikuli.script.Region.wait(Region.java:2222) at org.sikuli.script.Region.wait(Region.java:2240) at org.sikuli.script.Region.getLocationFromTarget(Region.java:3188) at org.sikuli.script.Region.click(Region.java:3806) at org.sikuli.script.Region.click(Region.java:3782) at Test.main(Test.java:9)
I made a search and I found another post related to this bug at https://answers.launchpad.net/sikuli/+question/668883 .
I made my first screenshot using Gnome screenshot and another screenshot using Gimp screenshot, however I still receiving the same error in the both case.
As you can see below, the picture spotlight.png seems to be found by Eclipse in the project. Thanks in advance for your help.
Upvotes: 0
Views: 3250
Reputation: 1
Using Sikuli we can process image
Screen S=new Screen();
//Settings image
//Play icon
Pattern Settingimg=new Pattern("C:\\Users\\Nalinikant\\Pictures\\Screenshots\\YT_settings.png");
S.wait(Settingimg,3000);
S.click();
Upvotes: 0
Reputation: 21
Good afternoon for this case I discovered that sikuli
does not automatically detect the root folder of the project. What you should do for this case is specify the folder using the command System.getProperty("user.dir")
;
import org.sikuli.script.*;
public class Test {
public static void main(String[] args) {
Screen s = new Screen();
try{
String pathYourSystem = System.getProperty("user.dir") + "\\";
s.click(pathYourSystem + "imgs/spotlight.png");
//s.wait(pathYourSystem + "imgs/spotlight-input.png");
//s.click();
s.write("hello world#ENTER.");
}
catch(FindFailed e){
e.printStackTrace();
}
}
}
Upvotes: 1
Reputation: 1143
The locations where you have stored your images must be registered in the SikuliX ImagePath. In your case it is the current working folder (project folder), when you run the stuff inside Eclipse.
Add this at the beginning of your main().
ImagePath.add(System.getProperty("user.dir"))
RaiMan from SikuliX
Upvotes: 2