python類比android螢幕高頻點擊工具

來源:互聯網
上載者:User

標籤:pip   process   alt   發送   out   mat   關閉   roc   windows   

一、環境

    windows 10  + python3.6

二、需求

    1、類比android裝置高頻點擊事件;

    2、類比規定次數的點擊事件或類比規定時間內的點擊事件;

三、code

    1、類比規定時間內的點擊事件 

 1 #!/usr/bin/env python3  2 # coding=utf-8 3  4 import subprocess 5 import time 6  7  8 def loop_click_for_android(run_time=5): 9     res = subprocess.Popen(‘adb devices‘,10                            shell=True, stdout=subprocess.PIPE)11     res.stdout.read()12     inputs = str(input("請確保已開啟測試頁面(y/n): "))13 14     if inputs == "y":15         num = 016         node_time = time.time()17         start_buttun = subprocess.Popen("adb shell input tap 600 1660")18         if start_buttun:19             while True:20                 result = subprocess.Popen("adb shell input tap 600 1660")21                 if result:22                     num += 123                     if node_time + run_time <= time.time():24                         break25                     else:26                         continue27         print("發送點擊次數{}".format(num))   # 次數統計並不準確28     else:29         print("程式關閉~")30         exit(1)31 32 33 loop_click_for_android()

    2、類比規定次數的點擊事件

 1 # !/usr/bin/env python3 2 # coding=utf-8 3  4 import subprocess 5 import time 6  7  8 def loop_click_for_android(run_num=150): 9     res = subprocess.Popen(‘adb devices‘,10                            shell=True, stdout=subprocess.PIPE)11     res.stdout.read()12     inputs = str(input("請確保已開啟測試頁面(y/n): "))13 14     if inputs == "y":15         num = 016         node_time = time.time()17         start_buttun = subprocess.Popen("adb shell input tap 600 1660")18         if start_buttun:19             while True:20                 result = subprocess.Popen("adb shell input tap 600 1100")21                 if result:22                     num += 123                     if num == run_num:24                         break25                     else:26                         continue27         over_time = time.time()28         print("{}次點擊的已耗用時間是:{}".format(run_num, over_time-node_time))   # 次數統計並不準確29     else:30         print("程式關閉~")31         exit(1)32 33 34 loop_click_for_android()

 

python類比android螢幕高頻點擊工具

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.