Operations 5 min read

Python Script for Automating Random WeChat Emoji Spam

This article provides a Python script that uses the pynput library to automate keyboard and mouse actions, randomly sending a wide range of WeChat emoji expressions to a chat window, with user‑controlled repeat count and interactive prompts for continued execution.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Python Script for Automating Random WeChat Emoji Spam

This tutorial presents a Python program that leverages the pynput library to control the keyboard and mouse, enabling automatic sending of random WeChat emoji expressions.

# -*- coding = utf-8 -*- # @Time : 2021/1/26 15:19 # @Author : 陈良兴 # @File : 微信表情包炸群.py # @Software : PyCharm from pynput.keyboard import Controller as KB # control keyboard input from pynput.mouse import Controller, Button # control mouse click import time import random Wechat_expression = [ "[微笑]","[撇嘴]","[色]","[发呆]","[得意]","[流泪]","[害羞]","[闭嘴]","[睡]","[大哭]","[尴尬]", "[发怒]","[调皮]","[呲牙]","[惊讶]","[难过]","[囧]","[抓狂]","[吐]","[偷笑]","[愉快]","[白眼]", "[傲慢]","[困]","[惊恐]","[憨笑]","[悠闲]","[咒骂]","[疑问]","[嘘]","[晕]","[衰]","[骷髅]","[猪头]", "[敲打]","[再见]","[擦汗]","[抠鼻]","[鼓掌]","[坏笑]","[右哼哼]","[鄙视]","[委屈]","[快哭了]", "[阴险]","[亲亲]","[可怜]","[笑脸]","[生病]","[脸红]","[破涕为笑]","[恐惧]","[失望]","[无语]", "[嘿哈]","[捂脸]","[奸笑]","[机智]","[皱眉]","[耶]","[吃瓜]","[加油]","[汗]","[天啊]","[Emm]", "[社会社会]","[旺柴]","[好的]","[打脸]","[哇]","[翻白眼]","[666]","[让我看看]","[叹气]","[苦涩]", "[裂开]","[嘴唇]","[爱心]","[心碎]","[拥抱]","[强]","[弱]","[握手]","[胜利]","[抱拳]","[勾引]", "[拳头]","[OK]","[合十]","[啤酒]","[咖啡]","[蛋糕]","[玫瑰]","[凋谢]","[菜刀]","[便便]","[月亮]", "[太阳]","[礼物]","[红包]","[發]","[福]","[跳跳]","[发抖]","[转圈]","[炸弹]","[庆祝]","[烟花]" ] # Keyboard control function def keyboardInput(string): keyboard = KB() keyboard.type(string) # Mouse click function def mouseClick(): mouse = Controller() mouse.press(Button.left) mouse.release(Button.left) # Response function def response(number): time.sleep(5) # delay 5 seconds before responding for i in range(number): sentence = random.choice(Wechat_expression) keyboardInput(sentence) mouseClick() time.sleep(0.4) # interval between messages if __name__ == "__main__": while True: print("\033[1;32m发动机已启动,随时可以出发!\033[0m") Num = input("\033[1;32m请输入轰炸次数:\033[0m") if Num.isdigit(): response(int(Num)) print("\033[1;33m报告长官,轰炸完毕,请求下一步作战计划!!!\033[0m") else: print("\033[1;31m输入错误,请重新输入一个整数!!!\033[0m") answer = input("\033[1;34m是否执行下一次作战计划?(y 或者 n):\033[0m") if answer == "y": print("\033[1;33m继续轰炸!!!\033[0m") continue if answer == "n": print("\033[1;33m停止轰炸,给他们喘口气!!!\033[0m") break else: print("\033[1;31m输入错误,请输入“y”或者“n”!!!\033[0m")

The usage steps are: run the script, input the desired number of repetitions, open a WeChat chat window, place the mouse cursor over the send button, and the program will automatically type and send random emoji expressions. Screenshots illustrate each step.

Disclaimer: This code is provided for entertainment purposes only.

Original source: https://blog.csdn.net/weixin_46153372/article/details/113183632

emojiAutomationscriptingWeChatpynput
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.