-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDictApp.py
69 lines (61 loc) · 2 KB
/
DictApp.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
import pyttsx3
import os
import pyautogui
import webbrowser
from time import sleep
# start engine property
engine = pyttsx3.init("sapi5")
# providing voice to the assistant
voices = engine.getProperty("voices")
engine.setProperty('voice', voices[0].id)
# setting the rate of voice
engine.setProperty("rate", 200)
# talk to the user through device's speaker
def speak(audio):
engine.say(audio)
engine.runAndWait()
dictApp = {
"command prompt" : "cmd",
"word" : "winword",
"excel" : "EXCEL",
"google chrome" : "chrome",
"pycharm" : "pycharm64",
"edge" : "msedge",
"browser" : "firefox",
"powerpoint" : "POWERPNT",
"powershell" : "powershell",
"one note" : "onenote",
"media player" : "VLC",
"sublime text" : "C:\\Program Files\\Sublime Text\\sublime_text"
}
def openAppWeb(query):
speak("Working on that, sir")
if ".com" in query or ".co.in" in query or ".org" or ".ac.in" in query:
query = query.replace("open", "")
query = query.replace("jarvis", "")
query = query.replace("launch", "")
query = query.replace("slash", "/")
query = query.replace(" ", "")
webbrowser.open(f"https://www.{query}")
speak(f"Opening {query}")
else:
keys = list(dictApp.keys())
for app in keys:
if app in query:
speak(f"Opening {app}")
os.system(f"start {dictApp[app]}")
def closeAppWeb(query):
speak("Closing, sir")
if "one tab" in query or "1 tab" in query:
pyautogui.hotkey("ctrl","w")
speak("All tabs are closed, sir")
elif "to tabs" in query or "2 tabs" in query or "2 tab" in query or "to tab" in query or "too tabs" in query or "too tab" in query:
pyautogui.hotkey("ctrl","w")
sleep(0.5)
pyautogui.hotkey("ctrl","w")
speak("All tabs are closed, sir")
else:
keys = list(dictApp.keys())
for app in keys:
if app in query:
os.system(f"taskkill /f /im {dictApp[app]}.exe")