I have a program, which opens a program, then it copies and pastes a string into the program and after some time it copies a string from the program to the clipboard using a robot with ctrl+c. Then my program checks if the copied string contains a word, but instead of inspecting the recently copied string it uses the previous copied string of the beginning. Heres some code:
new ProcessBuilder("pathToProgram").start();
copy(STRING1);
paste();
Thread.sleep(x);
//Move mouse to a position
//robot uses ctrl+a
copy();
Thread.sleep(100);
clipboardData = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
system.out.println(clipboardData);
if(clipboardData.contains(String2){
//do some stuff
}
The system.out thing outputs just the value of String1 not the value string2. Thanks for your help.