@echo off set /a total_time=0 set /a slide_time=0 set /a swipe_speed=400 :loop set /a slide_time=%random% %% 3 + 3 set /a total_time=%total_time% + %slide_time% echo %slide_time% seconds slide, total %total_time% seconds adb shell input swipe 100 500 1000 500 %slide_time% %swipe_speed% timeout /t %slide_time% >nul if %total_time% leq 12600 goto loop echo Done! 给代码加上指定连接的设备功能

时间: 2024-02-16 16:05:30 浏览: 17
可以在代码前面加上以下命令,指定连接的设备: ``` adb devices adb -s 设备ID号 shell "your command" ``` 其中,`设备ID号`为连接设备的唯一标识符,可以在运行`adb devices`命令后查看。将`"your command"`替换为具体的命令即可。例如,将原代码中的`adb shell input swipe`替换为以下命令: ``` adb -s 设备ID号 shell input swipe ``` 即可指定连接的设备。
相关问题

@echo off set /a total_time=0 set /a slide_time=0 :loop set /a slide_time=%random% %% 3 + 3 set /a total_time=%total_time% + %slide_time% echo %slide_time% seconds slide, total %total_time% seconds adb shell input swipe 1000 500 100 500 %slide_time% timeout /t %slide_time% >nul if %total_time% leq 12600 goto loop echo Done!

好的,以下是加入滑动速度的代码: ```batch @echo off set /a total_time=0 set /a slide_time=0 set /a slide_distance=0 set /a slide_count=0 :loop set /a slide_time=%random% %% 3 + 3 set /a total_time=%total_time% + %slide_time% rem 计算每个小段需要滑动的距离和时间 set /a slide_distance=900 set /a slide_count=%random% %% 5 + 5 set /a slide_distance=%slide_distance% / %slide_count% set /a slide_time=%slide_time% / %slide_count% rem 输出当前滑动信息 echo %slide_count% slides, %slide_distance% pixels per slide, %slide_time% seconds per slide, total %total_time% seconds rem 逐个滑动小段距离 for /l %%i in (1,1,%slide_count%) do ( rem 计算当前位置 set /a start_x=1000-%%i*%slide_distance% set /a end_x=%start_x%-%slide_distance% rem 模拟人的滑动操作,每隔一段时间滑动一小段距离 adb shell input swipe %start_x% 500 %end_x% 500 %slide_time% timeout /t %slide_time% >nul ) if %total_time% leq 12600 goto loop echo Done! ``` 这段代码在每次循环中固定滑动距离为900,并随机生成滑动次数。然后计算每个小段需要滑动的距离和时间。在滑动的过程中,我们使用了一个for循环来逐个滑动小段距离,同时使用timeout命令来模拟人的操作。每个小段滑动的时间是刚才计算出来的,这样就可以实现模拟人类操作的滑动速度。 需要注意的是,这段代码仍然需要在Windows环境下运行,并且需要安装adb工具和安卓模拟器。另外,为了使用随机函数,需要将代码保存为.bat文件,而不是普通的文本文件。

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 修改这段代码,实现不离手滑动

要实现不离手滑动,可以使用`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,从而实现不离手滑动的效果。

相关推荐

void lv_example_scroll_2_dir(void) { #if 1 lv_obj_t* cont = lv_obj_create(lv_scr_act()); lv_obj_set_size(cont, 400, 300); lv_obj_add_flag(cont, LV_OBJ_FLAG_SCROLL_ONE); /*Allow max 1 page swipe*/ lv_obj_set_scroll_snap_x(cont, LV_SCROLL_SNAP_CENTER); /*Snap a page to the center*/ lv_obj_set_scrollbar_mode(cont, LV_SCROLLBAR_MODE_OFF); lv_obj_add_event_cb(cont, scroll_end_event, LV_EVENT_SCROLL_BEGIN/*LV_EVENT_ALL*//*LV_EVENT_SCROLL*//*LV_EVENT_SCROLL_END*/, NULL); lv_obj_add_event_cb(cont, scroll_end_event, LV_EVENT_SCROLL_END, NULL); lv_obj_center(cont); /*A grid for the left center and right pages*/ lv_coord_t col_dsc[] = { LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST }; lv_coord_t row_dsc[] = { LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST }; lv_obj_set_grid_dsc_array(cont, col_dsc, row_dsc); /*Create 5 pages*/ for (int i = 0; i < 10; i++) { lv_obj_t* obj = lv_obj_create(cont); lv_obj_set_size(obj, lv_pct(33), lv_pct(100)); lv_obj_t* label = lv_label_create(obj); lv_label_set_text_fmt(label, "Page %d", i); lv_obj_set_style_border_width(obj, 0, 0); } /*Page 2, 3 hidden, page 4, 0, 1 are placed to the grid */ //lv_obj_add_flag(lv_obj_get_child(cont, 2), LV_OBJ_FLAG_HIDDEN); //lv_obj_add_flag(lv_obj_get_child(cont, 3), LV_OBJ_FLAG_HIDDEN); //lv_obj_set_grid_cell(lv_obj_get_child(cont, 4), LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1); //lv_obj_set_grid_cell(lv_obj_get_child(cont, 0), LV_GRID_ALIGN_CENTER, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1); //lv_obj_set_grid_cell(lv_obj_get_child(cont, 1), LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(lv_obj_get_child(cont, 0), LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(lv_obj_get_child(cont, 1), LV_GRID_ALIGN_CENTER, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(lv_obj_get_child(cont, 2), LV_GRID_ALIGN_CENTER, 2, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(lv_obj_get_child(cont, 3), LV_GRID_ALIGN_CENTER, 3, 1, LV_GRID_ALIGN_CENTER, 0, 1); lv_obj_set_grid_cell(lv_obj_get_child(cont, 4), LV_GRID_ALIGN_CENTER, 4, 1, LV_GRID_ALIGN_CENTER, 0, 1); /*Be sure page 0 is centered*/ lv_obj_scroll_to_view(lv_obj_get_child(cont, 0), LV_ANIM_OFF); }帮我注释一下这段代码

最新推荐

recommend-type

Airtest和Poco下的滑动操作

下文将向大家讲述Airtest和poco下的swipe如何使用以及应用swipe解决跳过APP介绍页和连续滑动等实际应用的问题。 Airtest下的swipe接口 swipe接口实现在当前设备画面上进行一次滑动操作,它支持的平台有Android、IOS...
recommend-type

微信小程序swiper组件实现抖音翻页切换视频功能的实例代码

微信小程序用swiper组件实现仿抖音短视频上下划动整页切换视频功能demo 利用swiper组件可简单快速编写仿抖音短视频的功能 自动播放当前页视频 翻页停止播放当前页视频 并自动播放下页视频 有其他需求也可用 cover-...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

2. 通过python绘制y=e-xsin(2πx)图像

可以使用matplotlib库来绘制这个函数的图像。以下是一段示例代码: ```python import numpy as np import matplotlib.pyplot as plt def func(x): return np.exp(-x) * np.sin(2 * np.pi * x) x = np.linspace(0, 5, 500) y = func(x) plt.plot(x, y) plt.xlabel('x') plt.ylabel('y') plt.title('y = e^{-x} sin(2πx)') plt.show() ``` 运行这段
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

实现实时监控告警系统:Kafka与Grafana整合

![实现实时监控告警系统:Kafka与Grafana整合](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2pwZy9BVldpY3ladXVDbEZpY1pLWmw2bUVaWXFUcEdLT1VDdkxRSmQxZXB5R1lxaWNlUjA2c0hFek5Qc3FyRktudFF1VDMxQVl3QTRXV2lhSWFRMEFRc0I1cW1ZOGcvNjQw?x-oss-process=image/format,png) # 1.1 Kafka集群架构 Kafka集群由多个称为代理的服务器组成,这
recommend-type

导入numpy库,创建两个包含9个随机数的3*3的矩阵,将两个矩阵分别打印出来,计算两个数组的点积并打印出来。(random.randn()、dot()函数)

可以的,以下是代码实现: ```python import numpy as np # 创建两个包含9个随机数的3*3的矩阵 matrix1 = np.random.randn(3, 3) matrix2 = np.random.randn(3, 3) # 打印两个矩阵 print("Matrix 1:\n", matrix1) print("Matrix 2:\n", matrix2) # 计算两个数组的点积并打印出来 dot_product = np.dot(matrix1, matrix2) print("Dot product:\n", dot_product) ``` 希望