Take the 2-minute tour ×

I am trying to send touch events using batch files (.bat) and the adb shell.

I tried to re-send evets i get from the adb shell getevents, and it doesn't work even though the command passes without errors. and ideas ?

How do I simulate a touch-event and release-event on a given (x,y) coordinate using the ADB shell ?

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

Since it seems to change depending on the Android version, I suggest you to follow these instructions :

  1. Start dump motion event you need to reproduce:

~$ adb shell getevent | grep event2

grep is very useful to filter output.

  1. Do motion event you want to reproduce;

  2. Then just convert all values from hex in dump to decimal values! :)

To find what eventX is working for you do following:

  1. Start terminal and type

~$ adb shell getevent

You will see quickly moving traces with for example /dev/input/event4 ......

  1. Touch screen once

You must see between event4 few eventX and these eventX right in the moment of the touch

will be yours input interface for reproducing motion events! :)

Source: http://softteco.blogspot.com/2011/03/android-low-level-shell-click-on-screen.html

Hope it helps!

share|improve this answer
Please provide a complete answer, instead of just a link. Links can go away, change, etc, so the answer will be unusable. –  Nanne Dec 27 '11 at 18:30
Post edited. :) –  krz37 Dec 27 '11 at 18:41
add comment

I managed to emulate the event on sony xperia LT26i by using

adb shell getevent | grep event2

to capture input and then converting all values from hex to decimal, and by putting the generated sequence in a shellscript

adb shell sendevent /dev/input/event2 3 57 23710
adb shell sendevent /dev/input/event2 3 53 329
adb shell sendevent /dev/input/event2 3 54 1183 
adb shell sendevent /dev/input/event2 3 52 0
adb shell sendevent /dev/input/event2 0 0 0
adb shell sendevent /dev/input/event2 3 57 4294967295
adb shell sendevent /dev/input/event2 0 0 0

I figured from posts in linked forum that line 2 and 3 are setting X and Y position the next 2 lines are touch press and the bottom 2 lines are touch release, I havent figured out what the first line does yet but it is needed for it to work. I hope this is useful to you

share|improve this answer
add comment

Your Answer


