sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #05255
[Question #170984]: Using the native getClipboard method in eclipse
New question #170984 on Sikuli:
https://answers.launchpad.net/sikuli/+question/170984
I'm making use of the following class for accessing information that's on the clipboard because the sikuli method (env.getClipboard) only works once in a while. However, I also get the error that's shown below when I use the java class. Any assistance on how to overcome this will be much appreciated:
Using: Sikuli-r830
Class:
public static String getClipboard() {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
try {
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String text = (String) t.getTransferData(DataFlavor.stringFlavor);
return text;
}
} catch (Exception e) {
}
return "";
}
Error:
Exception in thread "main" java.lang.IllegalStateException: cannot open system clipboard
at sun.awt.windows.WClipboard.openClipboard(Native Method)
at sun.awt.datatransfer.ClipboardTransferable.<init>(Unknown Source)
at sun.awt.datatransfer.SunClipboard.getContents(Unknown Source)
The error only occurs if I try to run another iteration right after the first one is complete
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.