SamJ
SamJ

Reputation: 423

Fast Keyevent Simulation (Android Shell)

Using adb shell input text <String> or adb shell input keyevent <KEYCODE_NAME> works perfectly fine in sending text to the android device, but my issue is speed.

Using something like input keyevent KEYCODE_A KEYCODE_A KEYCODE_SPACE KEYCODE_A KEYCODE_ENTER; will type the text quickly, but separating it into 2 commands will result in a (1 sec) delay between the 2 commands (Much Slower).

Sample Shell Code:

Method 1 (Much faster):

input keyevent KEYCODE_A KEYCODE_A KEYCODE_ENTER KEYCODE_A KEYCODE_A KEYCODE_ENTER;

Method 2:

input keyevent KEYCODE_A KEYCODE_A KEYCODE_ENTER;
input keyevent KEYCODE_A KEYCODE_A KEYCODE_ENTER;

I would like to type a large text as fast as possible, but having a shell script with input keyevent followed by a large combination of KEYCODE_A for instance, will not be executed. (Large Shell Commands are aborted)

What would be the best way to send large text without having long delays?
Would sendevent be faster in sending large text?

Note:

Thanks in Advance.

Upvotes: 2

Views: 2509

Answers (1)

Knossos
Knossos

Reputation: 16058

I realise you are after Android Shell, but I think you have exhausted the options available to you there.

I know of one way that is faster than what you have tried, using Instrumentation:

final Instrumentation mInst = new Instrumentation();

mInst.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN, keycode));
mInst.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP, keycode));

Upvotes: 3

Related Questions