P
patrick
Hello,
Im trying to delete and clear a textfield in another application from a
java application.(before inserting my own digits) but the code below only
works some of the time.The cursor will end up at left of any digits in the
field with digits uncleared a lot of the time.
Any ideas why??
patrick
//click mouse in field first then press keys
robot.mouseMove(x,y);
robot.mousePress(InputEvent.BUTTON1_MASK );
robot.mouseRelease(InputEvent.BUTTON1_MASK );
//clear
//clear by back spacing
for(int i=0;i<15;i++)
{
robot.keyPress(KeyEvent.VK_RIGHT);robot.keyRelease(KeyEvent.VK_RIGHT);
robot.keyPress(KeyEvent.VK_RIGHT);robot.keyRelease(KeyEvent.VK_RIGHT);
}
for(int i=0;i<15;i++)
{
robot.keyPress(KeyEvent.VK_BACK_SPACE);robot.keyRelease(KeyEvent.VK_BACK_SPA
CE);
robot.keyPress(KeyEvent.VK_BACK_SPACE);robot.keyRelease(KeyEvent.VK_BACK_SPA
CE);
}
//the delete key should work this doesnt work at all i think.
// for(int i=0;i<15;i++)
// {
//
robot.keyPress(KeyEvent.VK_DELETE);robot.keyRelease(KeyEvent.VK_DELETE);
//
robot.keyPress(KeyEvent.VK_DELETE);robot.keyRelease(KeyEvent.VK_DELETE);
// }
Im trying to delete and clear a textfield in another application from a
java application.(before inserting my own digits) but the code below only
works some of the time.The cursor will end up at left of any digits in the
field with digits uncleared a lot of the time.
Any ideas why??
patrick
//click mouse in field first then press keys
robot.mouseMove(x,y);
robot.mousePress(InputEvent.BUTTON1_MASK );
robot.mouseRelease(InputEvent.BUTTON1_MASK );
//clear
//clear by back spacing
for(int i=0;i<15;i++)
{
robot.keyPress(KeyEvent.VK_RIGHT);robot.keyRelease(KeyEvent.VK_RIGHT);
robot.keyPress(KeyEvent.VK_RIGHT);robot.keyRelease(KeyEvent.VK_RIGHT);
}
for(int i=0;i<15;i++)
{
robot.keyPress(KeyEvent.VK_BACK_SPACE);robot.keyRelease(KeyEvent.VK_BACK_SPA
CE);
robot.keyPress(KeyEvent.VK_BACK_SPACE);robot.keyRelease(KeyEvent.VK_BACK_SPA
CE);
}
//the delete key should work this doesnt work at all i think.
// for(int i=0;i<15;i++)
// {
//
robot.keyPress(KeyEvent.VK_DELETE);robot.keyRelease(KeyEvent.VK_DELETE);
//
robot.keyPress(KeyEvent.VK_DELETE);robot.keyRelease(KeyEvent.VK_DELETE);
// }