gpt4 book ai didi

android - 如何使用 sendevent 和 adb 使用 'duration' 执行滑动

转载 作者:行者123 更新时间:2023-12-04 11:04:04 27 4
gpt4 key购买 nike

我正在使用上面的代码来模拟使用 sendevent 的“滑动”:

sendevent /dev/input/event0 3 53 300 ;First position X
sendevent /dev/input/event0 3 54 600 ;First position Y
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 3 53 300 ;Second position X
sendevent /dev/input/event0 3 54 400 ;Second position Y
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
但是,它确实会立即滑动,没有任何延迟。
我试图弄清楚如何指定滑动的持续时间,就像您可以使用 adb shell 输入一样: input [touchscreen|touchpad|touchnavigation] swipe <x1> <y1> <x2> <y2> [duration(ms)] shell input swipe 300 400 300 200 2000这会产生持续时间为 2 秒的滑动。
我试图添加一个 sleep 2;Second position 之前但它确实会导致在滑动之前暂停,而不是持续 2 秒的滑动。
我的意思是持续时间,时间慢慢地从位置 1 交换到位置 2。

最佳答案

这样做的问题是通过 sendevent 发送事件需要一些时间。我做了一个 python script (您可以从那里获取所需的任何内容)在给定点之间插入点。它还在点之间等待一段时间。
这是线性插值代码:

def lerp(p1:tuple, p2:tuple, points:int) -> list:
output = []
header = [_p2 - _p1 for _p1, _p2 in zip(p1, p2)]
for p in range(points + 1):
percent = p / points
output.append((p1[0] + percent * header[0], p1[1] + percent * header[1]))
return output
使用多个点时会出现时间问题。使用具有 10 个插值点且它们之间没有时间的路径已经花费了 1.29 秒和 100 个点,即 11.45。

关于android - 如何使用 sendevent 和 adb 使用 'duration' 执行滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68839878/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com