Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to delete text from a text field using monkeyrunner API (Python script)

I am trying to delete text from a text field using monkeyrunner API . I am writing script in python.

There are key events like " KEYCODE_FORWARD_DEL","KEYCODE_DEL" and to move the cursor to the end "KEYCODE_MOVE_END".

I am trying to delete text, for this, I tried to move the cursor to the end but"KEYCODE_MOVE_END" did not work. Cursor did not move at all.

Then, I tried to use " KEYCODE_FORWARD_DEL" but it also did not work.

These, keys are working for the text field in which I entered text using my script, but these are not working for the fields, which were already filled.

Can any one, please guide me?

like image 822
blackfyre Avatar asked Jul 21 '26 05:07

blackfyre


1 Answers

This worked for me, though haven't tried setting a Exchange account:

  fieldLength = 50
  # select all the chars
  self.device.press('KEYCODE_SHIFT_LEFT', MonkeyDevice.DOWN)
  for i in range(fieldLength):
     self.device.press('KEYCODE_DPAD_LEFT', MonkeyDevice.DOWN_AND_UP)
     MonkeyRunner.sleep(1)
  self.device.press('KEYCODE_SHIFT_LEFT', MonkeyDevice.UP)

  # delete them
  self.device.press('KEYCODE_DEL', MonkeyDevice.DOWN_AND_UP)
like image 133
Diego Torres Milano Avatar answered Jul 23 '26 18:07

Diego Torres Milano