Spam Bot using PyAutoGUI

Last Updated : 17 Jan, 2026

A spam bot is a program that automatically sends repeated messages to a target platform, chat or application. Spamming is the act of sending the same message repeatedly. Using Python’s PyAutoGUI library, we can automate mouse movements, keyboard inputs and clicks to simulate human actions.

Prerequisites

  • Python version: 3.x
  • PyAutoGUI install

If PyAutoGUI is not installed, install it using below command in command prompt:

pip install pyautogui

Python Implementation

Below is the Python code for a spam bot using PyAutoGUI.

Python
import pyautogui
import time
import datetime

time.sleep(2)

while True:
    print(datetime.datetime.now())
    pyautogui.typewrite("Reminder: Drink water!")
    pyautogui.press("enter")
    time.sleep(31)

    print(datetime.datetime.now())
    pyautogui.typewrite("Reminder: Take medicine!")
    pyautogui.press("enter")
    time.sleep(31)

    print(datetime.datetime.now())
    pyautogui.typewrite("Reminder: Take the dog for a walk!")
    pyautogui.press("enter")
    time.sleep(31)

Output

au
Snapshot of the Terminal

Explanation:

  • time.sleep(2): Wait 2 seconds before starting so you can focus on the target window.
  • while True: Run an infinite loop to repeat the messages continuously.
  • print(datetime.datetime.now()): Print the current date and time in the terminal.
  • pyautogui.typewrite("<message>"): Type the message automatically.
  • pyautogui.press("enter"): Press Enter to send the message.
  • time.sleep(31): Wait 31 seconds before sending the next message.

Applications of a Spam Bot

  • Send reminders at regular intervals.
  • Automate notifications for personal tasks.
  • Can be used in messaging apps like WhatsApp, Telegram, or Discord.
Comment