简易实现自动签到并发送通知邮件

环境准备

Windows操作系统+adbshell1.0.40+pyhon3.7+visual stdio code stable+android手机+数据线,并配置环境变量

打卡程序

需要定位屏幕坐标

python 复制代码
import os
import time

a0=os.popen("adb shell input keyevent 26")
##b=a0.read()
##print(b)
time.sleep(5)     ##等待5秒
a1=os.popen("adb shell input swipe 767 1500 767 500")
time.sleep(5)
a2=os.popen("adb shell input tap 632 1605")
time.sleep(5)
a3=os.popen("adb shell input tap 330 610")
time.sleep(5)
a4=os.popen("adb shell input text xxxx")     ##DD密码
time.sleep(5)
a5=os.popen("adb shell input tap 945 752")
time.sleep(5)
a6=os.popen("adb shell input tap 783 1980")
time.sleep(5)
a7=os.popen("adb shell input tap 100 1017")
time.sleep(5)
a8=os.popen("adb shell input tap 770 630")
time.sleep(5)
a9=os.popen("adb shell input tap 801 1408")
time.sleep(5)
a10=os.popen("adb shell screencap -p /sdcard/1.png")   ##截图
time.sleep(5)

## ****3.发送邮件程序****
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
import time

my_date=time.strftime('%m-%d',time.localtime(time.time()))         ##格式化本地日期、时分秒
my_time=time.strftime('%H:%M:%S',time.localtime(time.time()))
my_timestamp=my_date+' '+my_time

my_sender='xxxxx'    ##发送账号
my_pass = 'xxxxxx'          ##邮箱密码    
my_user='xxxx'     ##接收账号
def mail():                              ##定义邮件函数,结果初始为成功,若try下面有一个执行失败,就返回失败结果
    result=True
    try:
        
        ##msg=MIMEText(my_content,'html','utf-8')      ##html格式邮件,测试时用了一下
        ##msg=MIMEMultipart('related')                 ##带附件邮件,测试时用了一下
        msg=MIMEMultipart()                 ##多个附件模式
        msg['From']=formataddr(["xxx",my_sender])      ##发送人代称及账户
        msg['To']=formataddr(["xxx",my_user])     ##发送人代称及账户
        msg['Subject']="dingdingdaka"    ##标题

        ##msgAlternative = MIMEMultipart('alternative')
        ##msg.attach(msgAlternative)
        msg.attach(MIMEText(my_timestamp, 'plain', 'utf-8'))    ##正文,写时间

        my_att1=MIMEText(open('1.png', 'rb').read(), 'base64', 'utf-8')         ##通过open函数打开截图并读取,若没有截图会正常关闭
        my_att1["Content-Type"] = 'application/octet-stream'      ##流模式
        my_att1["Content-Disposition"] = 'attachment; filename="1.png"'     ##附件名称

        msg.attach(my_att1)

 
        server=smtplib.SMTP_SSL("smtp.qq.com", 465)     ##smtp服务器
        server.login(my_sender, my_pass)
        server.sendmail(my_sender,[my_user,],msg.as_string())
        server.quit()
    except Exception: 
        result=False
    return result
    
my_result=mail()
if my_result:
    print("success")
else:
    print("fail")

定时任务

在任务计划程序添加任务,python xxx.py

相关推荐
都叫我大帅哥1 小时前
Python的Optional:让你的代码优雅处理“空值”危机
python
曾几何时`3 小时前
基于python和neo4j构建知识图谱医药问答系统
python·知识图谱·neo4j
写写闲篇儿6 小时前
Python+MongoDB高效开发组合
linux·python·mongodb
杭州杭州杭州7 小时前
Python笔记
开发语言·笔记·python
路人蛃8 小时前
通过国内扣子(Coze)搭建智能体并接入discord机器人
人工智能·python·ubuntu·ai·aigc·个人开发
qiqiqi(^_×)8 小时前
卡在“pycharm正在创建帮助程序目录”
ide·python·pycharm
Ching·9 小时前
esp32使用ESP-IDF在Linux下的升级步骤,和遇到的坑Traceback (most recent call last):,及解决
linux·python·esp32·esp_idf升级
吗喽15434518810 小时前
用python实现自动化布尔盲注
数据库·python·自动化
hbrown10 小时前
Flask+LayUI开发手记(十一):选项集合的数据库扩展类
前端·数据库·python·layui
猫头虎10 小时前
什么是 npm、Yarn、pnpm? 有什么区别? 分别适应什么场景?
前端·python·scrapy·arcgis·npm·beautifulsoup·pip