一、环境

windows 10  + python3.6

二、需求

1、模拟android设备高频点击事件;

2、模拟规定次数的点击事件或模拟规定时间内的点击事件;

三、code

1、模拟规定时间内的点击事件

 #!/usr/bin/env python3
# coding=utf-8 import subprocess
import time def loop_click_for_android(run_time=5):
res = subprocess.Popen('adb devices',
shell=True, stdout=subprocess.PIPE)
res.stdout.read()
inputs = str(input("请确保已打开测试页面(y/n): ")) if inputs == "y":
num = 0
node_time = time.time()
start_buttun = subprocess.Popen("adb shell input tap 600 1660")
if start_buttun:
while True:
result = subprocess.Popen("adb shell input tap 600 1660")
if result:
num += 1
if node_time + run_time <= time.time():
break
else:
continue
print("发送点击次数{}".format(num)) # 次数统计并不准确
else:
print("程序关闭~")
exit(1) loop_click_for_android()

2、模拟规定次数的点击事件

 # !/usr/bin/env python3
# coding=utf-8 import subprocess
import time def loop_click_for_android(run_num=150):
res = subprocess.Popen('adb devices',
shell=True, stdout=subprocess.PIPE)
res.stdout.read()
inputs = str(input("请确保已打开测试页面(y/n): ")) if inputs == "y":
num = 0
node_time = time.time()
start_buttun = subprocess.Popen("adb shell input tap 600 1660")
if start_buttun:
while True:
result = subprocess.Popen("adb shell input tap 600 1100")
if result:
num += 1
if num == run_num:
break
else:
continue
over_time = time.time()
print("{}次点击的运行时间是:{}".format(run_num, over_time-node_time)) # 次数统计并不准确
else:
print("程序关闭~")
exit(1) loop_click_for_android()

python模拟android屏幕高频点击工具的更多相关文章

  1. Android与.Net交互模拟用户屏幕操作添加APN和网络4G/3G切换

    前几天接到一个需求,我们的客户需要对手机网络接入点进行可用性测试,简单点说就是需要实现Android上的APN配置的添加,APN切换网络模式4G/3G/2G切换,我要调研下写个demo. 因为是要实现 ...

  2. 收藏的技术文章链接(ubuntu,python,android等)

    我的收藏 他山之石,可以攻玉 转载请注明出处:https://ahangchen.gitbooks.io/windy-afternoon/content/ 开发过程中收藏在Chrome书签栏里的技术文 ...

  3. uiautomator2 使用Python测试 Android应用

    GitHub地址:https://github.com/openatx/uiautomator2 介绍 uiautomator2 是一个可以使用Python对Android设备进行UI自动化的库.其底 ...

  4. Android 常用的性能分析工具详解:GPU呈现模式, TraceView, Systrace, HirearchyViewer(转)

    此篇将重点介绍几种常用的Android性能分析工具: 一.Logcat 日志 选取Tag=ActivityManager,可以粗略地知道界面Displaying的时间消耗.当我们打开一个Activit ...

  5. Android 发版的小工具

    Android加固包签名 我们知道自己的apk在上传市场的时候, 为了更好的包含我们的代码需要加固服务, 加固后的apk是不能直接安装的, 需要我们手动签名. 关于Android签名的知识就不在赘述了 ...

  6. 【译】android的审计和hacking工具

    原文:Best Android Tools For Security Audit and Hacking android系统占移动市场份额的80%且有恶意软件,这是一个问题.Hacker会对手机恶意操 ...

  7. 【Android应用开发】分享一个录制 Android 屏幕 gif 格式的小技巧

    因为写博客总是需要录制 Android 软件的演示效果, 研究了将近一小时找到了合适的工具; 录制流程 : -- 1. 录制 Android 手机屏幕内容 : 使用 拍大师 软件录制 Android ...

  8. python模拟鼠标键盘操作 GhostMouse tinytask 调用外部脚本或程序 autopy右键另存为

    0.关键实现:程序窗口前置 python 通过js控制滚动条拉取全文 通过psutil获取pid窗口句柄,通过win32gui使程序窗口前置 通过pyauto实现右键菜单和另存为操作 1.参考 aut ...

  9. 【Android】让Python在Android系统上飞一会儿

    第一节 在手机上配置Python运行环境 1.下载和安装 Scripting Layer for Android (SL4A) Scripting Layer for Android (SL4A) 是 ...

随机推荐

  1. 自测之Lesson14:多线程编程

    题目:创建一个线程,并理清主线程结束时会发生什么. 代码: #include <stdio.h> #include <pthread.h> #include <unist ...

  2. C语言实训——扑克牌洗牌程序

    说明此程序本来是21点扑克程序的一个被调函数,在这里我单独将它拿出来作为一个小程序. #include<stdio.h> #include<time.h> #include&l ...

  3. c#和.net区别

    .net 包含两大部分:.net framework类库和公共语言运行库(CLR) .net framework类库,就是微软工程师写好的各种功能类,例如math类. 公共语言运行库:1.与操作系统进 ...

  4. oracle数据库之PL/SQL 块结构和组成元素

    一.PL/SQL 块 (一)PL/SQL 程序由三个块组成,即声明部分.执行部分.异常处理部分 PL/SQL 块的结构如下: 1.DECLARE /* 声明部分: 在此声明 PL/SQL 用到的变量, ...

  5. 算法与数据结构实验题 4.2 小 F 打怪

    ★实验任务 小 F 很爱打怪,今天因为系统 bug,他提前得知了 n 只怪的出现顺序以及击 倒每只怪得到的成就值 ai.设第一只怪出现的时间为第 1 秒,这个游戏每过 1 秒 钟出现一只新怪且没被击倒 ...

  6. linux下php环境配置

    参: http://www.laozuo.org/5542.html LAMP,基于Linux/Apache/MySQL/PHP架构的网站建设环境,对于一般的网站来说足够使用,如果我们的网站访问量或者 ...

  7. Android 如何判断CPU是32位还是64位

    转自:http://blog.csdn.net/wangbaochu/article/details/47723265 1. 读取Android 的system property ("ro. ...

  8. 第四部分shell编程5项目二分发系统

    第一部分:expect讲解expect可以让我们实现自动登录远程机器,并且可以实现自动远程执行命令.当然若是使用不带密码的密钥验证同样可以实现自动登录和自动远程执行命令.但当不能使用密钥验证的时候,我 ...

  9. CMD (sea.js)模块定义规范

    转自http://www.cnblogs.com/hongchenok/p/3685677.html   CMD 模块定义规范 在 Sea.js 中,所有 JavaScript 模块都遵循 CMD(C ...

  10. 当重写了 httpservlet重写了GenericServlet的init方法时候 必须显示调用GenericServlet的init方法时候 才能在别的方法(父类创建config实例) 例如 doget里面使用servletContext对象 不重写init 则可以直接使用