How to write java program in Sikuli?

可紊 提交于 2019-12-23 02:54:12

问题


I have recorded the GUI desktop application using SIKULI as below:

App.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe")
sleep(1)

type ("mganda1")
sleep(1)
click( ) //click OK

I want to convert this script into Java. So I am trying as below:

package com.arcot.test.vpn;
import org.sikuli.script.*;

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

    App myApp = new App("application-identifier") ;

    myApp.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe");

//How to simulate the type, sleep and click functions here?

I am searching for java examples to understand the objects relation and how to use it to simulate the recorded scripts. Please provide if any of you know the links that help me.

Best regards, Madhu


回答1:


After your program, proceed in following way:

package com.arcot.test.vpn;
import org.sikuli.script.*;

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

App myApp = new App("application-identifier") ;    

myApp.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe");

Kindly proceed in this way, -Create one image folder inside your package "img" -Copy all the respective images in the img folder -Assign the image names in a folder to a different variables

For doing operations, use follwing command:

s.type("mganda1");   
s.sleep(time);    
s.click("ok.png"); 

Regards, Npesik




回答2:


Madhu,

I'm not sure why you recorded the script to lunch that app with sikuli. All of the commands yu use don't invoke any images and can all be written without the sikuli ide.

I would make the following changes to your original sikuli/jython script

App.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe")

sleep(1)

//change to  
wait(path to image, FOREVER)
//By changing to a wait there is an implicit find as defined by the path to the image

type ("mganda1")
//if there are issues verifying focus invoke type with the img option

sleep(1)
//use wait instead of sleep
click( ) //click OK
//What are you clicking on?

Regarding Java, here's the link to Sikuli javadocs



来源:https://stackoverflow.com/questions/5473465/how-to-write-java-program-in-sikuli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!