1
|
|
|
import tkinter as tk |
2
|
|
|
from tkinter import messagebox, StringVar, IntVar, Tk, Entry, \ |
3
|
|
|
Label, PhotoImage, Button, Text, Scrollbar, Y, RIGHT, YES, BOTH, \ |
4
|
|
|
Spinbox |
5
|
|
|
from tkinter import ttk |
6
|
|
|
import pywhatkit |
7
|
|
|
from pywhatkit import prnt_sleeptm, sleeptm |
8
|
|
|
import time |
9
|
|
|
import sys |
10
|
|
|
from PIL import Image, ImageTk |
11
|
|
|
|
12
|
|
|
win = Tk() # Bg_Col #1B1B19 |
13
|
|
|
win.geometry("500x400+400+100") |
14
|
|
|
win.resizable(0,0) |
15
|
|
|
win.title("AutoWhatsapp Message") |
16
|
|
|
|
17
|
|
|
cust_font = font = ('Consolas', 12) |
18
|
|
|
width = 500 |
19
|
|
|
height = 400 |
20
|
|
|
img = Image.open("Assets/whatsapp_bg.png") |
21
|
|
|
img = img.resize((width, height), Image.ANTIALIAS) |
22
|
|
|
photoImg = ImageTk.PhotoImage(img) |
23
|
|
|
wb = Label(win, image=photoImg) |
24
|
|
|
wb.pack() |
25
|
|
|
|
26
|
|
|
MobNum = StringVar() |
27
|
|
|
Mob2msg = StringVar() |
28
|
|
|
hour = IntVar() |
29
|
|
|
minutes = IntVar() |
30
|
|
|
|
31
|
|
|
Number = Label(win, text="Enter the Mobile No", |
32
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
33
|
|
|
Number.place(x=55, y=70) |
34
|
|
|
|
35
|
|
|
Message = Label(win, text="Enter the Message", |
36
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
37
|
|
|
Message.place(x=55, y=120) |
38
|
|
|
|
39
|
|
|
hourlabel = Label(win, text="Enter Schedule Time", |
40
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
41
|
|
|
hourlabel.place(x=55, y=220) |
42
|
|
|
|
43
|
|
|
Shutdown_label = Label(win, text="Enter Shutdown Timer", |
44
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
45
|
|
|
Shutdown_label.place(x=55, y=270) |
46
|
|
|
|
47
|
|
|
hrs_label = Label(win, text="hrs", |
48
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
49
|
|
|
hrs_label.place(x=300, y=220) |
50
|
|
|
|
51
|
|
|
mins_label = Label(win, text="mins.", |
52
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
53
|
|
|
mins_label.place(x=390, y=220) |
54
|
|
|
|
55
|
|
|
shut_label = Label(win, text="seconds.", |
56
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
57
|
|
|
shut_label.place(x=340, y=270) |
58
|
|
|
|
59
|
|
|
Entrynum = Entry(win, textvariable=MobNum, font=cust_font) |
60
|
|
|
Entrynum.insert(0,"+91") |
61
|
|
|
Entrynum.place(x=250, y=70) |
62
|
|
|
|
63
|
|
|
Entrymsg = Text(win, font=cust_font) |
64
|
|
|
Entrymsg.place(x=250, y=120, width=185, height=70) |
65
|
|
|
|
66
|
|
|
hours = Spinbox(win, textvariable=hour, font=cust_font, from_=0, to=23) |
67
|
|
|
hours.place(x=250, y=220, width=50) |
68
|
|
|
|
69
|
|
|
mins = Spinbox(win, textvariable=minutes, font=cust_font, from_=0, to=59) |
70
|
|
|
mins.place(x=340, y=220, width=50) |
71
|
|
|
|
72
|
|
|
sleep = IntVar() |
73
|
|
|
def shut_timer(): |
74
|
|
|
sh_time = sleep.get() |
75
|
|
|
if sh_time == 0: |
76
|
|
|
try: |
77
|
|
|
pywhatkit.cancelShutdown() |
78
|
|
|
messagebox.showinfo("Shutdown Timer", "Shutdown timer is not fixed") |
79
|
|
|
except NameError: |
80
|
|
|
messagebox.showinfo("Shutdown Timer", "Shutdown timer is not fixed") |
81
|
|
|
elif sh_time <= 86400: |
82
|
|
|
print(sh_time) |
83
|
|
|
messagebox.showinfo("Shutdown Timer", "When we sent WhatsApp message PC will shutdown after fixed timer") |
84
|
|
|
#pywhatkit.shutdown(time=sh_time) |
85
|
|
|
else: |
86
|
|
|
messagebox.showinfo("Shutdown Timer", "Shutdown timer is Greater than 24hrs.") |
87
|
|
|
|
88
|
|
|
def go(): |
89
|
|
|
print(sleeptm) |
90
|
|
|
messagebox.showinfo("AutoWhatsappMessage", |
91
|
|
|
"Will open web.whatsapp.com at before 1 minute of Scheduled time and message \ |
92
|
|
|
will be send Automatically at Scheduled time exactly Given") |
93
|
|
|
try: |
94
|
|
|
num = MobNum.get() |
95
|
|
|
msg = Entrymsg.get("1.0", "end-1c") |
96
|
|
|
hr = hour.get() |
97
|
|
|
mini = minutes.get() |
98
|
|
|
shut_timer() |
99
|
|
|
pywhatkit.sendwhatmsg(num, msg, hr, mini) |
100
|
|
|
except pywhatkit.CallTimeException: |
101
|
|
|
messagebox.showerror("AutoWhatsAppMessage", |
102
|
|
|
"Set Schedule time More than 1 minute from Current Time") |
103
|
|
|
except pywhatkit.CountryCodeException: |
104
|
|
|
messagebox.showerror("AutoWhatsAppMessage", |
105
|
|
|
"Please Ensure the mobile number & Coutry code.") |
106
|
|
|
|
107
|
|
|
sleep_time = Spinbox(win, textvariable=sleep, font=cust_font, from_=0, to=86399) |
108
|
|
|
sleep_time.place(x=250, y=270, width=80) |
109
|
|
|
|
110
|
|
|
GoCheck = Button(win, text="Start Schedule", command=go, font=cust_font) |
111
|
|
|
GoCheck.place(x=160, y=345) |
112
|
|
|
|
113
|
|
|
label = Label(win, |
114
|
|
|
text="Time must be in 24 hours Format & Country Code is Must.", |
115
|
|
|
font=cust_font, bg="#1B1B19", fg="#ffffff") |
116
|
|
|
|
117
|
|
|
import AddOn |
118
|
|
|
infinity = 1 |
119
|
|
|
while infinity == 1: |
120
|
|
|
for i in range(500): |
121
|
|
|
xpos = i |
122
|
|
|
label.place(x=xpos, y=20) |
123
|
|
|
time.sleep(0.01) |
124
|
|
|
if xpos == 500: |
125
|
|
|
xpos = 0 |
126
|
|
|
win.update() |
127
|
|
|
|
128
|
|
|
def on_close(): |
129
|
|
|
win.destroy() |
130
|
|
|
#import AddOn |
131
|
|
|
sys.exit() |
132
|
|
|
|
133
|
|
|
win.protocol("WM_DELETE_WINDOW", on_close) |
134
|
|
|
import AddOn |
135
|
|
|
win.mainloop() |
136
|
|
|
|