pyautogui实现微信自动回复和其他功能

1.代码

代码如下(示例):

import pyautogui
import pyperclip
import time
import cv2

def mouseclick(img):
    location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
    if location is not None:
        pyautogui.click(location.x*1680/3360,location.y*1050/2100,clicks=1,interval=0.2,duration=0.2,button="left")#
        return True
    else:
        return False

def dotask(a):
    
    if a["type"]=="点击":
        img=a["content"]
        return mouseclick(img)
    elif a["type"]=="输入":
        text=a["content"]
        # print(text)
        pyperclip.copy(text)# pyautogui.typewrite(text)
        pyautogui.hotkey('command','v')
        pyautogui.press('enter')
        return True

#点击输入内容脚本
def ops(b,c):#c是内容
    
    if b=='wx':
        while True:
            tasklist=[
            {"type":"点击","content":"微信接收图标路径/*.png"},
            {"type":"输入","content":c}
            ]
            dotask({'type':'点击','content':'微信图标路径/*.png'})
            i=0
            while i<len(tasklist):
                if(dotask(tasklist[i])):
                    i+=1
                else:
                    print('监听中...')
    elif b=='sf':
        
        loc = "浏览器图标路径/*.png"
        scaleClick(loc)
        pyautogui.hotkey('command','t')
        pyperclip.copy(c)
        pyautogui.hotkey('command','v')
        pyautogui.press('enter')
# print(pyautogui.size())

def scaleClick(loc):
    getloc=pyautogui.locateCenterOnScreen(loc,confidence=0.9)
    x,y = getloc
    pyautogui.click(x*1680/3360,y*1050/2100,duration=0.2)#本机为mac,分辨率要*相应值
ops('sf','输入搜索内容')

总结

b为sf是浏览器,打开浏览器,显示内容c的结果
b为wx是微信,打开微信,打开接受一次信息的输入框,发送内容c

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值