def out_hand_swipe(pos_list, duration): conmmd = r'input swipe %s %s %s %s %s' % (pos_list[0][0], pos_list[0][1], pos_list[1][0], pos_list[1][1], duration) # print(conmmd) device.shell(conmmd) def loop_move_task(): # 循环移动指定坐标组 global dict_info global is_on_page global is_start try: pos_list = dict_info['swipe_pos'] swipe_pos = [[int(int(width) * pos_list[0][0]), int(int(height) * pos_list[0][1])], [int(int(width) * pos_list[1][0]), int(int(height) * pos_list[1][1])]] print("转换后的滑动坐标列表:%s" % swipe_pos) back_pos = [swipe_pos[1], swipe_pos[0]] random_speed = dict_info['random_speed'] time.sleep(1) is_on_page = True if is_move: while is_start: speed = rand_speed(random_speed) out_hand_swipe(swipe_pos, speed) out_hand_swipe(back_pos, speed) except Exception as e: is_on_page = False is_start = False print('<br>滑动方法调用异常: %s <br>' % traceback.format_exc()) return 修改这段代码,实现不离手滑动
时间: 2024-03-02 17:53:06 浏览: 117
要实现不离手滑动,可以使用`adb shell input swipe`命令的`--pointer`参数。该参数用于设置滑动时触摸点的数量。将`--pointer`参数设置为2,则表示滑动时需要两个触摸点,即一个按下,一个松开,从而实现滑动。
以下是修改后的代码示例:
```python
def out_hand_swipe(pos_list, duration):
# 使用两个触摸点进行滑动
conmmd = r'input swipe --pointer 2 %s %s %s %s %s' % (pos_list[0][0], pos_list[0][1], pos_list[1][0], pos_list[1][1], duration)
# print(conmmd)
device.shell(conmmd)
def loop_move_task():
# 循环移动指定坐标组
global dict_info
global is_on_page
global is_start
try:
pos_list = dict_info['swipe_pos']
swipe_pos = [[int(int(width) * pos_list[0][0]), int(int(height) * pos_list[0][1])],
[int(int(width) * pos_list[1][0]), int(int(height) * pos_list[1][1])]]
print("转换后的滑动坐标列表:%s" % swipe_pos)
back_pos = [swipe_pos[1], swipe_pos[0]]
random_speed = dict_info['random_speed']
time.sleep(1)
is_on_page = True
if is_move:
while is_start:
speed = rand_speed(random_speed)
out_hand_swipe(swipe_pos, speed)
out_hand_swipe(back_pos, speed)
except Exception as e:
is_on_page = False
is_start = False
print('<br>滑动方法调用异常: %s <br>' % traceback.format_exc())
return
```
修改后的代码使用了`--pointer`参数,将触摸点数设置为2,从而实现不离手滑动的效果。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)