python adb控制手机制作剑气除魔游戏辅助

  • python adb控制手机进行操作
  • 游戏脚本流程

python adb控制手机进行操作

做好准备:
手机或者是模拟器都可以,手机的话usb线连接电脑开启调试模式,不会开启的手机型号过多自行百度吧,本次实验使用的是模拟器 分辨率为900x1600,模拟器比较简单直接点开软件就可以,
python环境
adb.exe
ColorSPY 2.0b 获取当前像素颜色的软件非常好用

原理:
python语言功能强大,使用os.system()相当于在Windows的cmd窗口中输入的命令,adb命令也可以在cmd里操作,也就是python可以操作adb了,那这样的话就可以实现 打开软件,关闭软件截屏上传截屏到电脑模拟点击。在根据截屏定位到像素点,获取像素点的的RGB颜色来确定脚本是否进行下一步,


#查看当前是否连接手机
os.system('adb devices')
#使用adb命令对手机进行截屏
os.system('adb shell /system/bin/screencap -p /sdcard/screenshot.png')
#使用adb命令对手机截屏进行上传电脑到当前目录下
os.system('adb pull /sdcard/screenshot.png')
#使用adb命令对手机进行点击
os.system('adb shell input tap 100 100')
#启动游戏软件/查找到软件的包名和类名才可以使用
os.system('adb shell am start -n com.jqcm.gw/com.only.sdk.h5app.h5Activity')
#关闭游戏软件
os.system('adb shell am force-stop com.jqcm.gw')

游戏脚本流程

首先我们打开游戏登陆,进入后先是离线经验进行领取,在去招募是否有免费英雄,然后在去坊市购买蓝色功法,然后在关闭游戏,间隔30分钟进行一次循环

先导入

import os
import time
from PIL import Image

先启动游戏对界面进行截图

#启动游戏软件/查找到软件的包名和类名才可以使用
os.system('adb shell am start -n com.jqcm.gw/com.only.sdk.h5app.h5Activity')
#使用adb命令对手机进行截屏
os.system('adb shell /system/bin/screencap -p /sdcard/screenshot.png')
#使用adb命令对手机截屏进行上传电脑到当前目录下
os.system('adb pull /sdcard/screenshot.png')

用电脑画图工具打开图片
鼠标放到想要点击的位置 在画图工具左下角显示的是像素 地址
放到免费位置 显示

获取到了免费按钮位置的像素点:224,1009

接下来注释掉打开游戏,截屏,上传到电脑
使用adb命令对手机进行点击

#使用adb命令对手机 224 和 1009 像素点位置 进行点击
os.system('adb shell input tap 224 1009')

在使用刚才查找免费按钮的方法 查找招募按钮
获得像素地址为:60,950

#使用adb命令对手机 60 和 950 像素点位置 进行点击
os.system('adb shell input tap 60 950')

进入招募页面在根据获取 “下次免费” 这几个字中的 随便一个像素点进行定位 获取到像素点的颜色,我定位的是759,922 此像素点在收费时RGB为 253, 125, 78 根据定位的像素点和收费的RGB进行if判断,
如果像素点和收费的RGB一样,则找游戏空白处进行点击,空白处一样也是用画图工具查找像素点,如果不一样,进行点击“招一次”的像素点,在点击一下空白处,像素点根据上面方法进行查找。

#使用adb命令对手机进行截屏
os.system('adb shell /system/bin/screencap -p /sdcard/screenshot.png')
#使用adb命令对手机截屏进行上传电脑到当前目录下
os.system('adb pull /sdcard/screenshot.png')
image = Image.open('screenshot.png')zhaomu = image.getpixel((759, 922))[:3]shoufei = (253, 125, 78)if zhaomu == shoufei:os.system('adb shell input tap 433 1537')else:os.system('adb shell input tap 730 835')time.sleep(2)os.system('adb shell input tap 433 1537')

接下来就是坊市了,方法和上面的招募一样,要先进行截图寻找像素点进行定位,在根据颜色判断,

os.system('adb shell input tap 386 520')
tiaoguo()
os.system('adb shell input tap 800 625')
tiaoguo()os.system('adb shell /system/bin/screencap -p /sdcard/screenshot.png')
os.system('adb pull /sdcard/screenshot.png')image = Image.open('screenshot.png')
gongfa1 = image.getpixel((25, 860))[:3]
gongfa2 = image.getpixel((315, 860))[:3]
gongfa3 = image.getpixel((607, 860))[:3]
gongfa4 = image.getpixel((25, 1020))[:3]
gongfa5 = image.getpixel((315, 1020))[:3]
gongfa6 = image.getpixel((607, 1020))[:3]
nengmai = (48, 255, 234)
if gongfa1 == nengmai:os.system('adb shell input tap 150 860')os.system('adb shell input tap 750 980')os.system('adb shell input tap 665 1140')os.system('adb shell input tap 196 1106')print('购买蓝色功法')
if gongfa2 == nengmai:os.system('adb shell input tap 440 860')os.system('adb shell input tap 750 980')os.system('adb shell input tap 665 1140')os.system('adb shell input tap 196 1106')print('购买蓝色功法')
if gongfa3 == nengmai:os.system('adb shell input tap 730 860')os.system('adb shell input tap 750 980')os.system('adb shell input tap 665 1140')os.system('adb shell input tap 196 1106')print('购买蓝色功法')
if gongfa4 == nengmai:os.system('adb shell input tap 150 1000')os.system('adb shell input tap 750 980')os.system('adb shell input tap 665 1140')os.system('adb shell input tap 196 1106')print('购买蓝色功法')
if gongfa5 == nengmai:os.system('adb shell input tap 440 1000')os.system('adb shell input tap 750 980')os.system('adb shell input tap 665 1140')os.system('adb shell input tap 196 1106')print('购买蓝色功法')
if gongfa6 == nengmai:os.system('adb shell input tap 730 1000')os.system('adb shell input tap 750 980')os.system('adb shell input tap 665 1140')os.system('adb shell input tap 196 1106')print('购买蓝色功法')

写完后改成函数
添加一个循环,添加启动游戏–点击进入–点击免费经验–点击招募–点击坊市–关闭游戏–半小时后再次进入循环–
让每次点击后都间隔10秒,每次点击完成后都点回伙伴,回到主页

while True:os.system('adb shell am start -n com.jqcm.gw/com.only.sdk.h5app.h5Activity')  # 启动time.sleep(10)os.system('adb shell input tap 445 855')time.sleep(20)lixian()os.system('adb shell input tap 55 524')zhaomu()  time.sleep(10)fangshi()  time.sleep(10)os.system('adb shell am force-stop com.jqcm.gw')print('半小时后执行下一次 不可关闭')time.sleep(1800)

挂机功法每次更新的都买到了,此次只是来学习进步的,不破坏游戏环境,谢谢大家观看,

python adb控制手机制作剑气除魔游戏辅助相关推荐

  1. python+ADB实现手机控制(2021淘宝的喵糖活动自动点击)

    python+ADB实现手机控制(2021淘宝的喵糖活动自动点击) 背景 环境 ADB(Android 调试桥) python环境 手机环境 简单程序 背景 双十一 TaoBao的活动太折磨人了,要一 ...

  2. python写手机脚本脱离电脑_在手机里编写python脚本控制手机

    今天我有一个大胆的想法,想在手机里面编写python脚本自动化控制手机.既然有了这么大胆而想法,而且我还能实现,那么就有了我现在这篇文章. 如何在手机里面编程 首先先介绍一款能直接在手机里面运行代码的 ...

  3. 安卓多台手机之间屏幕同步与pc通过adb控制手机

    最近有这样一个需求,多台手机之间,手机B,手机C,手机D全部显示手机A的屏幕或摄像头画面. 一开始为了快速实现,方案为手机A截屏,然后用socket发送给其余手机,效果实现,但是非常卡顿. 后来,想用 ...

  4. python uiautomator2控制手机点击_Python控制手机03-Uiautomator2配置

    0)前言 前面我们尝试了使用adb命令来控制手机,那么为什么需要uiautomator2呢? 可以这么理解,adb命令控制手机,需要熟悉android命令,相对较为复杂.而uiautomator2相当 ...

  5. 手机写python脚本_手机python在手机里写python脚本控制手机,神!

    一说起写代码,大家所想到地就是在电脑键盘上面敲.其实不然,在移动端飞速发展地今天,我们是可以在手机上编写代码的.今天,编玩编学网就给大家科普下手机python的知识,想在手机里面编写python脚本自 ...

  6. python+adb 控制安卓手机拍照并传电脑

    觉得USB摄像头拍照的效果太渣,特别是总有色差,也不会自动对焦等问题, 尝试研究运用手机摄像头拍照并传电脑,然后这几天接触了adb,最后顺利达成目标. 记录过程,代码在末尾: 1.安装 android ...

  7. python控制手机自动刷新闻_python +adb控制手机自动化签到

    #coding=utf8 importos,re,time,loggingimportpyautoguifrom apscheduler.schedulers.background import Ba ...

  8. python脚本控制手机app_Python+Appium学习之启动手机APP或者浏览器

    一.启动浏览器: pycharm中python脚本如下: 1 from appium importwebdriver2 3 desired_caps ={4 'platformName':'Andro ...

  9. python uiautomator2控制手机点击_uiautomator2 python远程操作Android

    上次写了一个Android自动化脚本,使用了appium和python-appium,刚开始使用时感觉很厉害,手机连上数据线之后,编写一系列代码就可以使Android自动操作,但是需要安装appium ...

最新文章

  1. 计算点云之间的平均距离,方差,标准差
  2. Ubuntu14.04 64位上配置终端显示git分支名称
  3. 基于wincc的虚拟电梯设计_基于WINCC的模拟电梯设计
  4. ‘%.2f‘ 与 ‘{:.2f}‘.format(w) 区别
  5. python mysqldb cursor_python中MySQLdb模块用法实例
  6. DataScience:数据可视化的简介(意义+六大优势)、使用工具之详细攻略
  7. html5 canvas图文编辑器源码_5个微信编辑器,再也不用为公众号发愁啦
  8. Google App Engine JAX-RS REST服务
  9. WCF Data Services 基础
  10. python 读取word_教你怎么使用 Python 对 word文档 进行操作
  11. 监督学习 | 决策树之Sklearn实现
  12. 关于PLSQL Developer报动态执行表不可访问,本会话的自动统计被禁止错的解决方法 .
  13. C# 如何理解如下泛型约束 class AT:where T:class{}
  14. 使用ArcMap将txt数据转换成shp数据
  15. MSDE 下载安装、创建管理数据库
  16. SQL Server 2000安装教程
  17. MUI框架的基本使用
  18. 地铁FAS设备组成及系统结构
  19. r7000屏幕亮度linux,联想legion R7000笔记本linux使用体验
  20. 学生管理系统报错合集

热门文章

  1. Unity 代码修改宏名并一键打包
  2. 解决真机识别为虚拟机,Sorry, this application cannot be run under a Virtual Machine
  3. Android集成环信IM,实现为某一个好友设置消息免打扰
  4. ThinkPHP中IP地址定位,包括IP地址库文件
  5. 山东法律学校97级计算机班,我校计算机学院97级计算机专业校友重聚母校
  6. [译]使用MVI打造响应式APP(三):状态折叠器
  7. [1]深入浅出工作开源框架Camunda: 安装和使用
  8. MCV EF增删改查
  9. 三菱FX系列PLC简单总结
  10. tesseract安装使用