PyAutoGUI 真正实现模拟键盘输入汉字方法

项目初衷为使用pyautogui模拟@微信里的人。不得不用typewriter,因汉字无法直接输入,那么就曲线救国。

步骤如下


import pypinyin

# 不带声调的(style=pypinyin.NORMAL)
def pinyin(word):
    s = ''
    for i in pypinyin.pinyin(word, style=pypinyin.NORMAL):
        s += ''.join(i)
    return s



def Aite(self,list):
    '''
        此处为@人的操作
    '''
    auto.hotkey("ctrl", "shift","1") # 切换至搜狗输入法中文模式
    for i in list:
            auto.hotkey("shift", "2")
            time.sleep(0.1)
            auto.typewrite(pinyin(i),0.1)
            auto.typewrite(' ')
            # time.sleep(0.2)
            wechat_locate7 = auto.locateCenterOnScreen(self.wechat_locate7_address)
            auto.click(wechat_locate7.x, wechat_locate7.y)  # 偏移点人





 说白了 就是模拟搜狗输入法挨个输字母然后敲空格

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值