I am trying to launch a chrome browser, select all then copy. the copy command (CTRL+C) seems to kill the console when running the jar file through a bat file.
public void sendKeys(key1, key2){
Robot robot=new Robot();
robot.keyPress(key1)
robot.keyPress(key2)
robot.keyrelease(key1)
robot.keyrelease(key2)
}
public void launchBrowser(){
launchBrowser();// launches browser using selenium
sendKeys("CTRL","A"); // Performs select All, works fine
sendKeys("CTRL","C"); // Copy the selected content to clipboard.
// CTRL+C works when i am in IDE, however if I run my jar file with console, CTRL+C kills the console.
}
I have tried to minimize the console which is running the program to make sure that it is in focus, but it doesn't seem to work.
I have also tried to run my program with javaw.exe instead of java so it will not give me a console, however that doesn't work either.
PS: The same code works on IDE flawlessly, as in when I run through eclipse. However when I deploy jars, it doesnt.