Passed
Push — master ( 56ea18...23ec5f )
by Deepak
55s
created

AutoWhatsApp.py (2 issues)

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