Is it possible to produce continuous swipe action on the touchscreen, with adb, on Android?

随声附和 提交于 2019-11-30 08:21:10

问题


I'm trying to reproduce swipe action, with the help of adb. Currently, this code works (for swipe)

adb shell input touchscreen swipe 530 1420 530 1120
adb shell input touchscreen swipe 530 1120 830 1120

which is

adb shell input touchscreen swipe x1,y1, x2,y2

but they are two discontinuous swipes.. Its equivalent to doing the first swipe, take ur hand off the screen and do the second swipe and so on..

I would like to achieve this as a single swipe.. Like, imagine a game where theres hot fire underneath and you have to drag om-nom across various obstacles without taking your finger off om-nom.. with the above mentioned adb swipe, poor om-nom would fall into the fire and become roasted-om-nom. :(

something like

adb shell input touchscreen swipe [(x1,y1, x2,y2), (x3,y3, x4,y4)...(xn-1,yn-1, xn,yn)]

if not adb, any other alternative?


回答1:


You can do it in ADB. Use getevent to record your manual input with:

adb shell getevent

Or to record a specific device:

adb shell getevent /dev/input/eventx

Then simuate recorded input with:

adb shell sendevent /dev/input/eventx



回答2:


adb shell  "input touchscreen swipe 126 459 413 472 & input command touchscreen swipe 413 472 407 769"

You must run inside android device input command, for continue swap add & between input command, example below:

adb shell "
   input touchscreen swipe 126 459 413 472 1000 & \ # 1th line 
   input touchscreen swipe 413 472 72  776 1000 & \ # 2th line
   input touchscreen swipe 72  776 407 769 1000 | echo done # 3th line" 


126 459   =   302 446   =   413 472
===================================
112 599   =   268 613   =   470 612
===================================
72  776   =   263 802   =   407 769

input touchscreen swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)

But need to make pausing or delaying (sleep,wait) between command's in order for more precise swipe.




回答3:


This works

$adb shell input touchscreen swipe x1 y1 & adb shell input touchescreen x2 y2 & adb shell input touchescreen x3 y3




回答4:


I think this will be a good option

for i in {1..5}; do adb shell input touchscreen swipe 530 1420 530 1120; adb shell input touchscreen swipe 530 1120 830 1120; done


来源:https://stackoverflow.com/questions/25500567/is-it-possible-to-produce-continuous-swipe-action-on-the-touchscreen-with-adb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!