如何在java程序中转换sikuli脚本

发布于 2024-11-24 07:41:47 字数 532 浏览 2 评论 0 原文

我已经使用 GUI 桌面应用程序记录了我的测试,让 SIKULI 单击闪存按钮。

现在我想在 Java 中使用我的 sikuli 脚本,如下所示:

import org.sikuli.script.*;

public class TestSikuli {

public static void main(String[] args) {
    Screen s = new Screen();
    try{

         s.wait("imgs/ViewPlaylist.png");
          s.click("imgs/ViewPlaylist.png", 0);

           s.type(null, "hello world\n", 0);
    }
    catch(FindFailed e){
            e.printStackTrace();
    }

}

但程序没有运行或显示任何输出。

你能看看代码并让我的 Java/Sikuli 脚本运行吗?

谢谢!

I have recorded my test using the GUI desktop application, HAVE SIKULI CLICK A FLASH BUTTON.

Now I would like to use my sikuli script in Java as per below:

import org.sikuli.script.*;

public class TestSikuli {

public static void main(String[] args) {
    Screen s = new Screen();
    try{

         s.wait("imgs/ViewPlaylist.png");
          s.click("imgs/ViewPlaylist.png", 0);

           s.type(null, "hello world\n", 0);
    }
    catch(FindFailed e){
            e.printStackTrace();
    }

}

But the program is not running or displaying any output.

Could u plz look into the code and make my Java/Sikuli script run.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一笑百媚生 2024-12-01 07:41:47

我相信您现在一定已经完成了此操作,但请仔细检查您是否已遵循此处列出的所有步骤 -

http://sikuli.org/wiki/How%20to%20use%20Sikuli%20Script%20in%20your%20JAVA%20programs
或者
http://sikuli.org/docx/faq/030-java-dev.html

如果是,请提供更多信息,说明您在执行这些步骤时是否遇到任何问题?

I believe you must have gone thru' this by now, but double check if you have followed all steps listed here -

http://sikuli.org/wiki/How%20to%20use%20Sikuli%20Script%20in%20your%20JAVA%20programs
OR
http://sikuli.org/docx/faq/030-java-dev.html

If yes, then provide more info on whether you got any problem in performing any of these steps?

纵情客 2024-12-01 07:41:47

private void click(String image) throws FindFailed{

Screen screen = new Screen();

Pattern pattern = new Pattern(image).similar((float) 0.7);

if(screen.find(pattern)!=null){ 
    screen.mouseMove(pattern); 
    screen.click(pattern); 
}
}

提供图像 URL(本地或网络上),此方法应该可以解决问题。它将鼠标移动到屏幕上的指定图像上,然后单击它......

private void click(String image) throws FindFailed{

Screen screen = new Screen();

Pattern pattern = new Pattern(image).similar((float) 0.7);

if(screen.find(pattern)!=null){ 
    screen.mouseMove(pattern); 
    screen.click(pattern); 
}
}

Provide the image URL (locally or on the web), and this method should do the trick. It moves the mouse to the specified image on the screen, and clicks on it...

荭秂 2024-12-01 07:41:47

试试这个

import org.sikuli.script.*;
import org.sikuli.basics.ImageLocator;
 public class TestSikuli {

public static void main(String[] args) {
Screen s = new Screen();
try{
  ImageLocator.setBundlePath("path to img directory");
     s.wait("ViewPlaylist.png");
      s.click("ViewPlaylist.png");

       s.type("hello world\n");
}
catch(FindFailed e){
        e.printStackTrace();
}

}

Try this

import org.sikuli.script.*;
import org.sikuli.basics.ImageLocator;
 public class TestSikuli {

public static void main(String[] args) {
Screen s = new Screen();
try{
  ImageLocator.setBundlePath("path to img directory");
     s.wait("ViewPlaylist.png");
      s.click("ViewPlaylist.png");

       s.type("hello world\n");
}
catch(FindFailed e){
        e.printStackTrace();
}

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文