Build a Message Bomber Using Python in Just 6 Lines of Code

Sai Ashish Konchada
4 min readFeb 11, 2021

Welcome to the Python Projects for Beginners Series ๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ

Iโ€™m Sai Ashish and today, Iโ€™m going to show you how to spam your friends by building a message bomber using just 6 lines of code๐Ÿ˜

How psyched are you for this build? Letโ€™s get started ๐Ÿš€

What are we going to learn today?

1. The PyAutoGUI module 
2. The Time module
3. Basics of Python: Iterative Statement
4. Implementation of Message Bomber Using Python with detailed explanation

P.S. Use this project wisely for fun purposes only. Donโ€™t go on spamming people and get blocked ๐Ÿ˜†

For this build, we are going to use the PyAutoGUI module of Python.

1. What is PyAutoGUI?

PyAutoGUI is a python module that lets you control your mouse and keyboard using a program.

To install PyAutoGUI in your system, open your terminal and run:

PyAutoGUI has several features including:

  • Moving the mouse and clicking or typing in the windows of other applications.
  • Sending keystrokes to applications (for example, to fill out forms).
  • Take screenshots, and given an image (for example, of a button or checkbox), find it on the screen.
  • Locate an applicationโ€™s window, and move, resize, maximize, minimize, or close it (Windows-only, currently)
  • Display message boxes for user interaction while your GUI automation script runs.

Source: Official documentation of PyAutoGUI.

PyAutoGUI also lets you automate your everyday tasks and can play games, login into emails, and more.

2. What is the Time Module?

The time module provides various time-related functions. We use it to retrieve the system time and display it on the screen. You can access the official documentation form here ๐Ÿ“„

3. Time to Code!

You can access the exclusive theory for this build here ๐Ÿ’ฃ

The first step is to import the PyAutoGUI and the Time module.

Next, we need to set the program to sleep for 10 seconds. youโ€™ll get to know the reason at the end of the implementation.

I plan to spam my friend with the script of the Green Lantern movie ๐Ÿฎ Sorry, Ryan ๐Ÿ˜ I already have downloaded the script of the movie. All I have to do is to load it into my environment.

Make sure to provide the full path of the file with an extension, if the file isnโ€™t located at the same location as the program. Otherwise, the name of the file with the extension is enough.

Youโ€™ve loaded the word bullets. Your program gun is on point. All thatโ€™s left to do is fire it ๐Ÿ”ฅ

for word in file: pyautogui.write(word) pyautogui.press('enter')

Here, we set a loop to iterate over each word in the file. We use write() function to type the keys and then use the press() function to click enter and send the message. Therefore, our message bomber takes each word from the file and spams right into where we want to.

Your program is ready. Let me show you how itโ€™s done ๐Ÿ˜Ž

Step 1: Open your Python environment ๐Ÿ
Step 2: Open the app through which you want to spam ๐Ÿ“ฑ
Step 3: Run the message bomber program ๐Ÿƒ๐Ÿปโ€โ™‚๏ธ
Step 4: Quickly switch the window from the python environment to the application and point the cursor on the userโ€™s chat area. We chose the delay of 10 seconds to perform this action in the meantime โณ
Step 5: Step back, grab some popcorn, and watch your bot unleash the power ๐Ÿฟ

The final source code looks like this:

If you do not want to use a file, you can just eliminate the file statement and use pyautogui.write("Random Annoying Spam Words") instead of pyautogui.write(word) while keeping a count loop.

We did it ๐Ÿฅณ We have made our own Message Bomber using Python in just 6 lines of code! How amazing is that? As a gift for staying till now, you get access to my Python For Beginners Series Repository ๐Ÿ˜ This repository contains all the source code youโ€™d need to get started as a Python Developer ๐Ÿ.

You can also download the source code to this project here. Do hit the twinkle star, if this article provided value to you ๐Ÿ”ฅ

And while youโ€™re at it, consider giving this blog the maximum love you can and I promise to give you such value bombs every week ๐Ÿ’ฃ Until then, take care ๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ

  • Interested in Building Your Own Artificial Intelligence Projects using Python?: Check out the Python AI Series ๐Ÿง 
  • Wanna Discover Some Valuable Tech-Hacks ๐Ÿ› ?: Check out the Tech-Hacks for Everybody Series ๐Ÿ˜Ž
  • Wanna Interact With Me ๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ? Connect With Me on Your Favourite Platform Here ๐Ÿค๐Ÿป
  • Find and Download All My Project Source Codes at My Github Repository ๐ŸŽ

Originally published at https://theinsightfulcoder.com.

--

--

Sai Ashish Konchada

Full Stack Developer ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป| Google DSC Lead 21 ๐Ÿง‘๐Ÿปโ€๐ŸŽ“ | AIR 102 Indiaโ€™s Super Brain ๐Ÿง | Top 50 Technical Blogger โœ๐Ÿป