This is more of a hypothetical question, I\'m brainstorming some ideas for a project that I\'m planning, and was curious if anyone knew of any APIs or methods of getting any
public static String getSelectedData() {
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
Thread.sleep(2*1000);
robot.keyPress(KeyEvent.VK_C);
Thread.sleep(2*1000);
robot.keyRelease(KeyEvent.VK_C);
Thread.sleep(2*1000);
robot.keyRelease(KeyEvent.VK_CONTROL);
Thread.sleep(2*1000);
} catch (Exception ex) {
System.out.println(ex);
}
String word = getSelectedData();
return word;
}
private static String getDataFromClipboard() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
try {
String result = (String) clipboard.getData(DataFlavor.stringFlavor);
return result;
} catch (Exception e) {
System.out.println("ERROR");
return null;
}
}