我需要从我的PC浏览文件到网络 我使用机器人方法
browseButton.click();
test.log(LogStatus.PASS, "Buttom is clicked");
setClipboardData**("C:\\SLT file\\small.stl**");
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
public void setClipboardData(String string)
{
StringSelection stringSelection = new StringSelection(string);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
}
有时它运作良好,有时会显示一个消息:
你知道为什么会这样吗?