Python analog Android Screen high frequency click Tool

Source: Internet
Author: User

First, the environment

Windows Ten + python3.6

Second, demand

1, analog Android device high-frequency click event;

2. Simulate the Click event of the specified number of times or simulate the click event within the specified time;

Third, code

1. Simulate Click events within a specified time

1 #!/usr/bin/env Python32 #Coding=utf-83 4 Importsubprocess5 Import Time6 7 8 defLoop_click_for_android (run_time=5):9res = subprocess. Popen ('ADB devices',TenShell=true, stdout=subprocess. PIPE) One Res.stdout.read () Ainputs = str (input ("Make sure the test page (y/n) is open:")) -  -     ifInputs = ="y": thenum =0 -Node_time =time.time () -Start_buttun = subprocess. Popen ("adb shell input tap 1660") -         ifStart_buttun: +              whileTrue: -result = subprocess. Popen ("adb shell input tap 1660") +                 ifResult: Anum + = 1 at                     ifNode_time + run_time <=time.time (): -                          Break -                     Else: -                         Continue -         Print("send clicks {}". Format (num))#count is not accurate -     Else: in         Print("Program Close ~") -Exit (1) to  +  -Loop_click_for_android ()

2. Simulate a specified number of click events

1 #!/usr/bin/env Python32 #Coding=utf-83 4 Importsubprocess5 Import Time6 7 8 defLoop_click_for_android (run_num=150):9res = subprocess. Popen ('ADB devices',TenShell=true, stdout=subprocess. PIPE) One Res.stdout.read () Ainputs = str (input ("Make sure the test page (y/n) is open:")) -  -     ifInputs = ="y": thenum =0 -Node_time =time.time () -Start_buttun = subprocess. Popen ("adb shell input tap 1660") -         ifStart_buttun: +              whileTrue: -result = subprocess. Popen ("adb shell input tap 1100") +                 ifResult: Anum + = 1 at                     ifnum = =Run_num: -                          Break -                     Else: -                         Continue -Over_time =time.time () -         Print("{} times the run time of the click is: {}". Format (Run_num, over_time-node_time))#count is not accurate in     Else: -         Print("Program Close ~") toExit (1) +  -  theLoop_click_for_android ()

Python analog Android Screen high frequency click Tool

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.