-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsendwhatsapp.py
41 lines (34 loc) · 1.36 KB
/
sendwhatsapp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# This script sends a message to a person on my WhatsApp multiple times. The web WhatsApp window(or the browser) should not be minimized.
# Compilation: > python sendwhatsapp.py
# Before compilation, you need the following packages, for which you need to run the following commands:
# sudo apt install python3-pip
# pip install pywhatkit
# sudo apt-get install python3-tk python3-dev (NOTE: You must install tkinter on Linux to use MouseInfo. Run this command.)
# pip install keyboard
# pip install pyautogui
# pip install time
import time
import pywhatkit
import pyautogui
from tkinter import *
from datetime import datetime
win = Tk()
screen_width = win.winfo_screenwidth()
screen_height = win.winfo_screenheight()
count = 0
while count <= 100:
now = datetime.now()
current_hour = now.hour
current_minute = now.minute
# Send the message
pywhatkit.sendwhatmsg("+xxxxxxxxxxxx", "<Message to be sent>", current_hour, current_minute + 1, 15)
# Press the Enter key after sending the control to the WhatsApp window (should not be minimized)
pyautogui.moveTo(screen_width * 0.694, screen_height * 0.964)
pyautogui.click()
pyautogui.press('enter')
# Add delay to ensure the message is sent before closing the tab
time.sleep(2)
# Close the tab
pyautogui.hotkey('ctrl', 'w')
# Move to the next iteration of the loop
count = count + 1