Thursday, 29 January 2015

Python script to print touch coordinates using getevent command

We have prepared a batch file containing two major commands described as below :

      1. adb shell getevent -c 200 > getevent.txt
       Description:
       The above command will create 200 events including the touch event given by user
       manually. The touch event given by user will be differentiated via 'event3'

How does getevent works ? 
adb shell getevent ( connect device and use this command )
Which returns something like:
C:\>adb shell getevent
add device 1: /dev/input/event0
name: “qwerty2″
could not get driver version for /dev/input/mouse0, Not a typewriter
could not get driver version for /dev/input/mice, Not a typewriter
/dev/input/event0: 0001 0001 00000000
/dev/input/event0: 0003 0000 00000073
/dev/input/event0: 0003 0001 000000a8
/dev/input/event0: 0003 0001 00000014
/dev/input/event0: 0003 0001 00000014
/dev/input/event0: 0003 0001 00000000
/dev/input/event0: 0003 0001 00000000
/dev/input/event0: 0003 0001 00000000
/dev/input/event0: 0001 014a 00000001
        Which returns everything in hexidecimal, but you can’t send these commands directly back, you         had to convert them to decimal,
The actual X axis coordinates : 00000073 
The actual Y axis coordinates : 000000a8
These coordinates needs to be changed to decimal using python and monkeyrunner

2. monkeyrunner.bat testcall3.py
Description :
This command will execute following functions :
a. Open the getevent text file
b. Search for the touch events ( eg., search for 'event3')
c. Display the Hex format coming infront of event3 lines
d. Convert hex to int and then to decimal
e. Finally display the X and Y coordinates

Continue sharing interesting scripts !!
Thanks !!!

2 comments:

  1. dude,if u r sharing code, just share code. If u don't want to share, then don't, which is fine.

    Don't post a god damn pic of code

    ReplyDelete
    Replies
    1. Hi Dear , I apologise for sharing pic of a code ! I will take this as a feedback and share the raw codes from next time onwards

      Delete