python实现按钮键盘交互发微信消息

打印 上一主题 下一主题

主题 894|帖子 894|积分 2682

  1. import time
  2. from pynput.keyboard import Key, Controller as key_cl
  3. from pynput.mouse import Button, Controller as mouse_cl
  4. def keyboard_input(string):
  5.     keyboard = key_cl()
  6.     keyboard.type(string)
  7. def mouse_click():
  8.     mouse = mouse_cl()
  9.     mouse.press(Button.left)
  10.     mouse.release(Button.left)
  11. def send_message(number, string):
  12.     print("The program will be excuted in 3 seconds")
  13.     time.sleep(3)
  14.     keyboard = key_cl()
  15.     mouse_click()
  16.     for i in range(number):
  17.         print(i)
  18.         keyboard_input(string)
  19.         time.sleep(0.3)
  20.         keyboard.press(Key.ctrl)
  21.         keyboard.press(Key.enter)
  22.         keyboard.release(Key.enter)
  23.         keyboard.release(Key.ctrl)
  24. if __name__ == "__main__":
  25.     s = "hello"
  26.     send_message(10, s)  # 10为发送次数,s为所要发送消息
  27.     time.sleep(1)  # 代表三秒后程序开始运行,你需要在限定时间内完成消息框定位单击操作
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

王海鱼

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表