Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can anyone explain this command fully adb shell sendevent [device] [type] [code] [value]? [closed]

Tags:

shell

adb

Can anyone explain the following command fully:

adb shell sendevent [device] [type] [code] [value]

I am trying to write a script for touch events using send event command.

like image 685
Jugal Avatar asked Jun 23 '13 10:06

Jugal


1 Answers

First you need to find out the name of the touchscreen device on your phone or tablet. You can use this command in adb shell session:

getevent -pl 2>&1 | sed -n '/^add/{h}/ABS_MT_TOUCH/{x;s/[^/]*//p}'

Let's say the input device name is /dev/input/event0 and you want to emulate a quick tap at coordinates x=300, y=400:

sendevent /dev/input/event0 3 53 300
sendevent /dev/input/event0 3 54 400
sendevent /dev/input/event0 3 48 5
sendevent /dev/input/event0 3 58 50
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0

The long touch (let's say 1sec long) at the same coordinates would be:

sendevent /dev/input/event0 3 53 300
sendevent /dev/input/event0 3 54 400
sendevent /dev/input/event0 3 48 5
sendevent /dev/input/event0 3 58 50
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0
sleep 1
sendevent /dev/input/event0 0 2 0
sendevent /dev/input/event0 0 0 0

For the explanation what those commands mean and do exactly please read Emulating touchscreen interaction with sendevent in Android.

like image 163
Alex P. Avatar answered Sep 18 '22 17:09

Alex P.