Python使用itchat模块实现简单的微信控制电脑功能示例
本文实例讲述了Python使用itchat模块实现简单的微信控制电脑功能。分享给大家供大家参考,具体如下:
#!/usr/bin/python
#coding=UTF-8
import requests, json
import itchat
import os,time,datetime
from PIL import ImageGrab
from itchat.content import *
app_dir = r''#打开一个程序,填写exe文件的绝对路径
imgdir = r'E:\test.jpg'
def file_edit(wr_str):
f1 = open(r'E:\downloadlog.txt','a')
f1.write(wr_str+'\n')
f1.close()
def pscr():#截取屏幕,保存图片到指定目录
im = ImageGrab.grab()
im.save(imgdir,'jpeg')
@itchat.msg_register([TEXT])
def text_reply(msg):
if u"开始" in msg['Content']:
itchat.send(u"收到开始指令,请稍等", msg['FromUserName'])
file_edit(str(datetime.datetime.now()))
time.sleep(3)
os.startfile(app_dir)
time.sleep(5)
itchat.send(u"已开始", msg['FromUserName'])
elif u'进度' in msg['Content']:
itchat.send(u"收到指令,请稍等", msg['FromUserName'])
pscr()
itchat.send(u"请接收图片", msg['FromUserName'])
itchat.send_image(imgdir.decode('utf-8'),msg['FromUserName'])
else:
pass
itchat.auto_login()
itchat.run()
发送其他消息
给自己发送消息只需要发出消息,不指定发送者,默认发给自己(登陆者)
itchat.send_msg('nice to meet you')
发送图片,ToUser不指定时发给自己
itchat.send_image(ImageName.decode('utf-8'),ToUser) # 发送图片
发送视频
itchat.send_video(VideoName.decode('utf-8'),ToUser) # 发送图片
发送文件
itchat.send_file(path.decode('utf-8')) # 图片(文件
更多关于Python相关内容感兴趣的读者可查看本站专题:《Python进程与线程操作技巧总结》、《Python Socket编程技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》
希望本文所述对大家Python程序设计有所帮助。
- Python分析微信好友性别比例和省份城市分布比例的方法示例【基于itchat模块】
- python基于itchat模块实现微信防撤回
- Python微信库:itchat的用法详解
- python基于itchat实现微信群消息同步机器人
- python实现微信接口(itchat)详细介绍
- python3操作微信itchat实现发送图片
- 利用python微信库itchat实现微信自动回复功能
- python使用itchat库实现微信机器人(好友聊天、群聊天)
- python itchat实现微信自动回复的示例代码
- python-itchat 获取微信群用户信息的实例
- python itchat实现微信好友头像拼接图的示例代码
- Python实现清理微信僵尸粉功能示例【基于itchat模块】
相关文章
Anaconda配置pytorch-gpu虚拟环境的图文教程
这篇文章主要介绍了Anaconda配置pytorch-gpu虚拟环境步骤整理,本文分步骤通过图文并茂的形式给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2020-04-04
Python matplotlib的spines模块实例详解
作为程序员,经常需要进行绘图,下面这篇文章主要给大家介绍了关于Python matplotlib的spines模块的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下2022-08-08
基于PyQt5实现SqlServer数据库表导出Excel表格小工具
这篇文章主要为大家详细介绍了PyQt5的应用案例之实现SqlServer数据库表导出Excel表格小工具,文中的示例代码讲解详细,需要的小伙伴可以参考一下2023-12-12


最新评论