python控制微信屏蔽,python控制微信实现关机、截屏、拍照

# -*- coding: utf-8 -*-

import itchat#安装pip install itchat

import os#用cmd系统指令

from PIL import ImageGrab#截屏pip install pillow

import cv2#摄像头pip install opencv-python

@itchat.msg_register(['Text'])

def message(msg):

print(msg)

ToUserName=msg['ToUserName']

data=msg['Text']

if ToUserName=='filehelper':

if data=='关机':

shutdown()

if data=='截屏':

screen()

if data=='拍照':

photo()

def shutdown():

os.system('shutdown /s /t 0')

def screen(fileName='screen.png'):

im=ImageGrab.grab(fileName='screen.png')

im.save(fileName)

itchat.send_image(fileNmae,'filehelper')

def photo(fileName='screen.png'):

cap=cv2.VideoCapture(0)#读第一个摄像头

ret,img=cap.read()

if ret:

cv2.imwrite(fileName,img)

itchat.send_image(fileName,'filehelper')

else:

itchat.send('摄像头不能用','filehelper')

cap.release

#登入并保存登入状态,实现第一次运行时扫码,一定时间内再次运行就不用扫码了,手机微信上将显示:网页微信已登入.....

itchat.auto_login(hotReload=True)

itchat.run()

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值