I have a java application in which i want to simulate ctrl c, ctrl v and ctrl x
here is a part of the code i used inside a mouse listener
else if(event.getActionCommand().equals("Cut"))
{
System.out.println("cut call");
robot.keyPress(KeyEvent.VK_CUT);
robot.keyRelease(KeyEvent.VK_CUT);
}
and this doesn t work
if i do a KeyEvent.VK_C instead per example it works c will appear in the textfield am targetting but copy wont work
i also try
else if(event.getActionCommand().equals("Cut"))
{
robot.keyPress(control);
robot.keyPress(KeyEvent.VK_X);
robot.keyRelease(KeyEvent.VK_X);
robot.keyRelease(control);
System.out.println("cut call");
}
no result
I am using a mac os but i test my code on window and as on mac no result.
The reason why i am using robot is because i want people to be able to copy from my application and to copy outside of my application
Thanks in advance
Ps
here is a code which i should have included
if(System.getProperty("os.name").startsWith("Mac OS"))
{
control = 157;
}
else
{
control = KeyEvent.VK_CONTROL;
}
157 is what i get when i press the apple key on my keybord