Skip to content
Related Articles

Related Articles

Improve Article

Spam bot using PyAutoGUI

  • Last Updated : 02 Feb, 2021

PyAutoGUI is a Python module that helps us automate the key presses and mouse clicks programmatically. In this article we will learn to develop a spam bot using PyAutoGUI.

Spamming – Refers to sending unsolicited messages to large number of systems over the internet. 

This mini-project can be used for many real-life applications like:

  • Remind your friends or relatives to do a particular task after every particular time interval
  • Can be used for advertisement purpose

In this article we will show the working of spam bot on telegram, but the code can also work for WhatsApp, Instagram etc. i.e. anywhere we find a text field it will work the same way.


  • Import module
  • Add delay of 2 second in the execution of the program
  • Create mechanism to generate text messages. typewrite() function of pyautogui helps to write the text and sleep function helps us specify the particular time interval (in seconds) after which the next instruction has to be executed. function helps the user keep a track of when the message was sent.



  • Execute code

Follow these simple steps to develop a spam bot using python:



import pyautogui, time, datetime
while True:
    # to display the time at which the message is sent 
    pyautogui.typewrite("Reminder: Drink water!""enter")
    pyautogui.typewrite("Reminder: Take medicine!")"enter")
    pyautogui.typewrite("Reminder: Take the dog for a walk!")"enter")
    pyautogui.typewrite("Reminder: Drink water!")"enter")
    pyautogui.typewrite("Reminder: Drink water!")"enter")


Date and time at which the message was sent 

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :