我正在自动化一个应用程序,其中机器人类首先单击取消按钮,然后单击菜单项,然后单击子菜单项。单击子菜单后,它必须等待(时间未知),因为它加载了一个环境,然后点击一个按钮。那么有什么方法让我可以等待那个特定的时间,它必须在任务完成时退出。它不应该等待更多或更少。
我提供的代码请帮助我实现此代码。
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
public class ChangeAsst {
public static void main(String[] args) throws AWTException, IOException {
Runtime.getRuntime().exec("C:\\Program Files\\PeopleSoft\\Change Assistant\\changeassistant.exe");
Robot robot = new Robot();
robot.delay(2000);
System.out.println(robot.isAutoWaitForIdle());
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_ALT);
/*
* this is where i want to implement the code so that it should wait for that particular time (it should not wait more or less)
* When environment loading is done it should exit from this and go to next line of code.
*
* I can use here as :
* robot.delay(10000);
* but it will wait for 10 seconds, even if loading is done in 3rd seconds also.
*/
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_T);
robot.delay(300);
robot.keyPress(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_ALT);
robot.delay(5000);
System.out.println(robot.isAutoWaitForIdle());
}
}