zoukankan      html  css  js  c++  java
  • Python实现定时监测屏幕

    实现手段:

    1、对屏幕定时截图

    2、将截图的图片通过邮件发送到邮箱

    依赖库:pillow,time,yagmail

    基础知识:1:发送邮件

         2:截图

         3、定时
    time.sleep(时间),默认为秒。

    完整实现代码:

    import yagmail
    from PIL import ImageGrab
    import time


    username = "xxxx@qq.com"#发送邮箱
    password = "xxxx"
    #设定发送的账户,方式
    yag = yagmail.SMTP(user=username, password=password, host='smtp.qq.com')
    #循环,也可以用while True来代替。
    for i in range(5):
    im = ImageGrab.grab() # 无参数默认全屏截屏
    im.save('shot.jpg') # 截图保存,默认是当前目录
    address = "xxxxx@qq.com"#发送到xxx邮箱
    # 标题
    title = [
    "测试邮件" + str(i+1)
    ]
    # 内容
    content = [
    "屏幕现况"
    , yagmail.inline("shot.jpg") # 插入图片并显示到正文
    ]
    # 4、发送邮件
    yag.send(to=address, subject=title, contents=content)
    # 5、关闭连接
    yag.close()
    time.sleep(10)#根据需求设定时间

    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _(手动分割线)

    博客小白,个人记录,很多待补充,想到再慢慢修改,欢迎批评指正。

    摘自:网络上很多的大神。侵删。。

    转载请附原文链接以及作者,谢谢。

    一个啥都想整小白白白。。。
    一个啥都想整小白白白。。。
  • 相关阅读:
    bzoj4358: permu
    bzoj4636: 蒟蒻的数列
    bzoj4229: 选择
    bzoj4561: [JLoi2016]圆的异或并
    bzoj2618: [Cqoi2006]凸多边形
    bzoj1803: Spoj1487 Query on a tree III
    bzoj2467: [中山市选2010]生成树
    PostgreSQL服务器存储参数的内部查看方法和实际表述之间的关系
    PostgreSQL 系统表
    PostgreSQL环境中查看SQL执行计划示例
  • 原文地址:https://www.cnblogs.com/sky-sugar/p/14717325.html
Copyright © 2011-2022 走看看