zoukankan      html  css  js  c++  java
  • Python实现一个简单的微信跳一跳辅助

    1.  前言

    微信的跳一跳相信大家都很熟悉了,而且现在各种外挂、辅助也是满天飞,反正本人的好友排行榜中已经是八九百都不足为奇了。某宝上一搜一堆结果,最低的居然只要3块多,想刷多少分就刷多少分,真是离谱。

    作为一枚程序猿,我决心也自己搞一下,不为别的,一来为了磨练一下自己的解决问题的能力,而来也为了娱乐一下。像这种任务,最适合的当然是Python,丰富的第三方库,而且具有胶水语言的特点。

    本程序的主要设计思路就是,PC端adb连接手机→截屏→在PC端展示→用户鼠标选取起点和终点→计算距离、时长→adb发送指令模拟按压→截屏循环。

    2.  ADB

    adb,Android Debug Bridge,即安卓调试桥,包含如下几个部分:

    • Client端, 运行在开发机器中,即你的开发PC机,用来发送adb命令
    • Deamon守护进程,运行在调试设备中,即的调试手机或模拟器
    • Server端,作为一个后台进程运行在开发机器中,即你的开发PC机,用来管理PC中的Client端和手机的Deamon之间的通信

    我们通常用的adb命令指的就是Client端程序。Server端实际上在本机侦听端口5037,将指令通过usb线/wifi转发给移动设备的Deamon进程。

    adb命令读者可以去官方网站查看文档(http://adbshell.com/commands),这里只介绍用到的几个命令。

    (1)    adb devices列出所有连接的模拟器/设备

    Prints a list of all attached emulator/device

    adb devices

    In response, return serial number and state

    e4b25377        device

    emulator-5554  device

    (2)    adb shell screencap截屏

    taking a screenshot of a device display.

    adb shell screencap <filename>

    adb shell screencap /sdcard/screen.png

    download the file from the device将文件从设备下载到本机。

    adb pull /sdcard/screen.png

    (3)    adb shell input swipe模拟滑动操作(长按)

    adb shell input swipe 100 100 100 100 500模拟长按坐标(100, 100)时长500ms

        C:Documents and SettingsAdministrator>adb shell  
        root@NX403A:/ # input  
        input  
        Usage: input [<source>] <command> [<arg>...]  
          
        The sources are:  
              trackball  
              joystick  
              touchnavigation  
              mouse  
              keyboard  
              gamepad  
              touchpad  
              dpad  
              stylus  
              touchscreen  
          
        The commands and default sources are:  
              text <string> (Default: touchscreen)  
              keyevent [--longpress] <key code number or name> ... (Default: keyboard)  
              tap <x> <y> (Default: touchscreen)  
              swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)  
              press (Default: trackball)  
              roll <dx> <dy> (Default: trackball)  

    好了,以上是本次所需adb的知识点。

    3.  Python

    (1)     调用命令行

    Python调用命令行有多种方式,比较常用的是os.system(cmd)和os.popen(cmd),以及commands.getoutput(cmd),这三者主要区别在返回值的获取方面,第一个无法获得返回值,第二、三个则可以获取。这里用哪个都可以,因为不需要获得返回值。

    (2)     OpenCV

    主要用OpenCV做一些图片缩放等操作,用PIL也是可以的。

    (3)     Tkinter

    主要用到了Button、PhotoImage这两个Widget。不多说了。

    程序的实现是很简单的,这里处于某些原因就不公开代码了,主要就是一个细调参数的过程。

    程序截图:

     

    下一步的目标是,结合OpenCV和神经网络实现自动识别、计算距离。

    郑重声明,本文仅供学习、娱乐只用,请勿随意传播。

  • 相关阅读:
    MySQL配置文件
    Linux安装MySQL以及版本说明
    RabbitMQ之Routing(路由有选择的接收)
    RabbitMQ之Publish/Subscribe(发布/订阅)
    RabibitMQ之Work Queues
    RabbitMQ简单生产者消费者(一对一)发送消息
    Linux下安装RabbitMQ
    PyQt5+qtdesigner开发环境配置
    利用sql语句建立全国省市区三级数据库
    完整项目:网上图书商城(一、MySQL数据库设计)未完
  • 原文地址:https://www.cnblogs.com/pleiades/p/8387934.html
Copyright © 2011-2022 走看看