【微信二狗成语接龙】

1.实现步骤

使用 uiautomation 找到微信窗口并监控
模拟点击消息 循环获取 群对话最后一条
获取后调用成语接龙api 获取接龙成果后 使用pyperclip 复制粘贴 发送消息

import random

import uiautomation as ui
import pyperclip
import  requests
wx  = ui.WindowControl(Name = "微信")

wx.SwitchToThisWindow()
hw = wx.ListControl(Name = "会话")
we = hw.TextControl(searchDepth=4)
we.Click(simulateMove=False)
kk= 0
ddd = []
while True:
    last_msg = wx.ListControl(Name = "消息").GetChildren()[-1].Name
    print(last_msg)
    # last_msg= "第3条:百战百胜"
    if last_msg:

        if "条:" in last_msg:
            ddd = []
            print("*****************")
            ll = []
            cheng = last_msg.split("条:")[-1]
            cheng = cheng.replace("👈","")
            cheng = cheng.replace("👉", "")
            res = requests.get("https://www.cyjl123.com/api/web/detail?word={}".format(str(cheng)))
            res = res.json()

            for i in range(int(len(res["result"]["candidate"]))):

                res_cheng = res["result"]["candidate"][i]["word"]
                ll.append(res_cheng)

            # input = int(input("其他跳过,1选择成语:  "))
            # if input == 1:


            print(ll)
            if ll == []:
                continue
            # res_ll = ll[0]
            res_ll = random.choice(ll)

            pyperclip.copy(res_ll)
            wx.SendKeys("{Ctrl}v", waitTime=0)
            wx.SendKeys("{Enter}", waitTime=0)
            ddd = ll
        elif "这不是成语" in last_msg:
            kk+=1
            if ddd == []:
                continue
            try:
             res_ll = ddd[kk]
            except:
                continue

            pyperclip.copy(res_ll)
            wx.SendKeys("{Ctrl}v", waitTime=0)
            wx.SendKeys("{Enter}", waitTime=0)





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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值