-
Notifications
You must be signed in to change notification settings - Fork 0
/
MusicPlayerAutomation.py
104 lines (84 loc) · 2.47 KB
/
MusicPlayerAutomation.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import pyautogui, time
import pyttsx3
# methods: (Start)
def output(text):
engine = pyttsx3.init()
rate = engine.getProperty("rate")
engine.setProperty(engine, rate-50)
engine.say(text)
engine.runAndWait()
engine.stop()
def start():
vlcIcon = pyautogui.locateCenterOnScreen("vlcIcon.PNG")
if vlcIcon:
pyautogui.click(vlcIcon)
else:
usrInput = input("The Media player is already open! do you want me to close it?: ")
output("The Media player is already open! do you want me to close it?")
if usrInput.lower() == "yes":
stop()
def stop():
vlcIcon = pyautogui.locateCenterOnScreen("playingVlcIcon.PNG")
if vlcIcon:
pyautogui.click(vlcIcon)
else:
output("The Media player is already closed! do you want me to open it?")
usrInput = input("The Media player is already closed! do you want me to open it?: ")
if usrInput.lower() == "yes":
start()
def back():
backbutton = pyautogui.locateCenterOnScreen("BackButton.PNG")
if backbutton:
pyautogui.click(backbutton)
else:
pyautogui.click(pyautogui.moveTo(212, 755))
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen("BackButton.PNG"))
def forward():
forwardbutton = pyautogui.locateCenterOnScreen("ForwardButton.PNG")
if forwardbutton:
pyautogui.click(forwardbutton)
else:
pyautogui.click(pyautogui.moveTo(212, 755))
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen("ForwardButton.PNG"))
def pause():
pausebutton = pyautogui.locateCenterOnScreen("PausedButton.PNG")
if pausebutton:
pyautogui.click(pausebutton)
else:
pyautogui.click(pyautogui.moveTo(212, 755))
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen("PausedButton.PNG"))
def play():
playbutton = pyautogui.locateCenterOnScreen("PlayButton.PNG")
if playbutton:
pyautogui.click(playbutton)
else:
pyautogui.click(pyautogui.moveTo(212, 755))
time.sleep(1)
pyautogui.click(pyautogui.locateCenterOnScreen("PlayButton.PNG"))
#methods (End)
# main program Start
dicto = {
"start": start,
"stop": stop,
"play": play,
"pause": pause,
"back": back,
"forward": forward
}
output("What would you like me to do: ")
# Say the function name one word i.e the function name like pause
usrInput = input("What would you like me to do: ")
while usrInput.lower() != "close":
found = False
for x in dicto:
if usrInput.lower() == x:
dicto[x]()
found = True
if found == False:
output("I cannot operate this function")
output("Anything else: ")
usrInput = input("Anything else: ")
# Main Program End