วันพฤหัสบดีที่ 9 กรกฎาคม พ.ศ. 2558

shell-batch-scripting-to-direct-commands-to-adb-shell

http://stackoverflow.com/questions/3474318/shell-batch-scripting-to-direct-commands-to-adb-shell

adb shell "sendevent /dev/input/event9 3 53 215;sendevent /dev/input/event9 3 54 68;sendevent /dev/input/event9 3 48 40;sendevent /dev/input/event9 3 50 6;sendevent /dev/input/event9 3 57 0;sendevent /dev/input/event9 0 2 0;sendevent /dev/input/event9 0 0 0;sendevent /dev/input/event9 3 53 215;sendevent /dev/input/event9 3 54 68;sendevent /dev/input/event9 3 48 0;sendevent /dev/input/event9 3 50 6;sendevent /dev/input/event9 3 57 0;sendevent /dev/input/event9 0 2 0;sendevent /dev/input/event9 0 0 0;"
The only thing you need to take care of is, that you do not feed in more than 25 (that's the amount I used, 30 doesn work anymore) sendevents, because else adb will throw the error, that there are too many arguments or so.


=========
adb shell "sendevent /dev/input/event0 3 0 281;
           sendevent /dev/input/event0 3 1 70;
           sendevent /dev/input/event0 1 330 1;
           sendevent /dev/input/event0 0 0 0;
           sendevent /dev/input/event0 1 330 0;
           sendevent /dev/input/event0 0 0 0;
           sendevent /dev/input/event0 1 330 1;
           sendevent /dev/input/event0 0 0 0;
           sendevent /dev/input/event0 1 330 0;
           sendevent /dev/input/event0 0 0 0;
           sendevent /dev/input/event0 0 0 0;
           sendevent /dev/input/event0 0 0 0"
shareimprove this answer
   
Just realized you're using a batch file. The above works in bash but I don't remember how DOS handles line continuation. Maybe this will work as-is? The semicolons are all that's necessary to issue multiple commands to adb shell (which is ash IIRC) –  Topher Sep 15 '11 at 16:19 
=====

(
   echo cd sdcard
   echo ls
) | adb shell
So it may work as below:
(
    echo am start -a android.intent.action.MAIN -n com.q.me.fui.activity/.InitActivity
    echo sleep 15
    echo sendevent /dev/input/event0 3 0 281
    echo sendevent /dev/input/event0 3 1 70
    echo sendevent /dev/input/event0 1 330 1
    echo sendevent /dev/input/event0 0 0 0
    echo sendevent /dev/input/event0 1 330 0
    echo sendevent /dev/input/event0 0 0 0   
    echo sendevent /dev/input/event0 1 330 1
    echo sendevent /dev/input/event0 0 0 0
    echo sendevent /dev/input/event0 1 330 0
    echo sendevent /dev/input/event0 0 0 0
    echo sendevent /dev/input/event0 0 0 0
    echo sendevent /dev/input/event0 0 0 0   
    echo sleep 5
    echo input keyevent 82
    echo input keyevent 20
    echo input keyevent 20
    echo input keyevent 22
    echo input keyevent 22
    echo input keyevent 22
    echo input keyevent 66
    echo sleep 5
) | adb shell

ไม่มีความคิดเห็น:

แสดงความคิดเห็น