whatsapp automated bot using python

introduction:

whatsapp automated bot using python are popular for automating tasks like sending messages or providing info. This article shows how to make one using Python and the pyautogui library.

if you want 1000+ python program PDF then :- click here

  1. Python pyautogui and Installation:

pyautogui is a Python library that enables programmatically controlling the mouse and keyboard to automate interactions with the graphical user interface (GUI). To install pyautogui, you can use pip, Python’s package manager, by executing the following command in your terminal or command prompt:

pip install pyautogui

This command will download and install the pyautogui library along with its dependencies.

  1. Code:

Below is a simple Python script demonstrating how to create a basic WhatsApp bot using pyautogui. This script automates the process of opening WhatsApp Web, selecting a contact, and sending a predefined message.

import pyautogui

import time

# Function to send message on WhatsApp

def send_whatsapp_message(contact_name, message):

    # Open WhatsApp Web

    pyautogui.hotkey('command', 'space')

    pyautogui.write('Google Chrome')

    pyautogui.press('enter')

    time.sleep(2)  # Wait for Chrome to open

    pyautogui.write('https://web.whatsapp.com/')

    pyautogui.press('enter')

    time.sleep(10)  # Wait for WhatsApp Web to load

    # Select contact

    pyautogui.click(x=100, y=200)  # Adjust coordinates based on your screen resolution

    pyautogui.write(contact_name)

    time.sleep(2)

    pyautogui.press('enter')

    # Send message

    pyautogui.write(message)

    pyautogui.press('enter')

# Example usage

contact = "John Doe"

message = "Hello, this is an automated message!"

send_whatsapp_message(contact, message)
  1. Video Tutorial:

For a more detailed walkthrough on creating a WhatsApp bot using Python and pyautogui, check out this comprehensive video tutorial

Conclusion:

With the power of Python and the pyautogui library, creating a WhatsApp bot for automating messaging tasks becomes straightforward. Whether you’re sending routine messages or providing real-time information, Python empowers you to streamline your workflow and increase efficiency.

Leave a Comment