python 控制android 手机发送消息

# -*- coding: utf-8 -*-
import os
import time
def doshell(cmd,str):
    print(" ",str,cmd)
    output = os.popen(cmd)
    a=output.read()
    print(a)
    output.close()

def sendmsg():
    n = 9
    index = 0
    text='adb shell input text  '
    text+=inputtext
    while index < n:
        cmd='adb shell input tap 500 '
        y = start + index*lenth
        cmd = cmd + str(y)
        doshell(cmd,'点击对话人')
        doshell('adb shell input tap 900 1900','点击发送按钮') #点击发送按钮
        doshell('adb shell input tap 200 1900','点击编辑框') #点击编辑框
        #doshell(text,'写入数据到编辑框') #写入数据到编辑框
        doshell('adb shell input keyevent 66','点击回车发送') #点击回车发送
        doshell('adb shell input tap 100 700','点击编辑框') #点击编辑框
        doshell('adb shell input keyevent 4','点击回车键')   #这条命令相当于按了设备的Backkey键
        doshell('adb shell input tap 400 1900','点击联系人') #点击联系人
        index += 1
w=1080
h=2016
start=380
lenth = 170
inputtext='https://mp.csdn.net/postedit/89531309'
doshell('adb shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.tencent.mobileqq/com.tencent.mobileqq.activity.SplashActivity','打开qq')

#点击联系人
doshell('adb shell input tap 400 1900','点击联系人')

#点击通讯录
doshell('adb shell input tap 800 1100','点击通讯录')

#点击通讯录
doshell('adb shell input swipe 50 1000 50 265 500','拖动位置到发送目标')
time.sleep(1)
while 1:
    sendmsg()
    doshell('adb shell input swipe 50 1685 50 500 500','换人')
 

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值