I am trying to save an image by using save as option inside a specific folder. I found a way by which I am able to right click on the image which I want to save using save a
Use the same Robot class and press enter to select the "Save" in the Windows dialog box.
robo.keyPress(KeyEvent.VK_ENTER); robo.keyRelease(KeyEvent.VK_ENTER);
if you need to rename it copy the file name in the clipboard and pass like below
StringSelection file = new StringSelection("D:\\image.jpg");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(file, null);
Robot rb = new Robot();
rb.setAutoDelay(2000); // Similar to thread.sleep
rb.keyPress(KeyEvent.VK_CONTROL);
rb.keyPress(KeyEvent.VK_V);
rb.keyRelease(KeyEvent.VK_CONTROL);
rb.keyRelease(KeyEvent.VK_V);
rb.setAutoDelay(2000);
rb.keyPress(KeyEvent.VK_ENTER);
rb.keyRelease(KeyEvent.VK_ENTER);