1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
public class MaClasse
{
public static void writeClipboard(String text)
{
try
{
StringSelection ss = new StringSelection(text);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,null);
}
catch( IllegalStateException e)
{
/** Le presse-papier n'est pas disponible */
}
}
public static void main(String[] args)
{
try
{
Robot r=new Robot();
writeClipboard("test@,;:!^");
r.keyPress(KeyEvent.VK_ALT);
r.keyPress(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_ALT);
r.delay(2000);
r.keyPress(KeyEvent.VK_CONTROL);
r.keyPress(KeyEvent.VK_V);
r.keyPress(KeyEvent.VK_V);
r.keyPress(KeyEvent.VK_CONTROL);
}catch(Exception e)
{
}
}
} |
Partager