-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDictapp.py
61 lines (55 loc) · 1.95 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
import os
import pyautogui
import webbrowser
import pyttsx3
from time import sleep
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
engine.setProperty("rate", 170)
def speak(audio):
print(f"Speaking: {audio}") # Debugging print statement
engine.say(audio)
engine.runAndWait()
dictapp = {"commandprompt":"cmd","paint":"mspaint","word":"winword","excel":"excel","chrome":"chrome","vscode":"code","powerpoint":"powerpnt"}
def openappweb(query):
speak("Launching, sir")
if ".com" in query or ".co.in" in query or ".org" in query:
query = query.replace("open","")
query = query.replace("jarvis","")
query = query.replace("launch","")
query = query.replace(" ","")
webbrowser.open(f"https://www.{query}")
else:
keys = list(dictapp.keys())
for app in keys:
if app in query:
os.system(f"start {dictapp[app]}")
def closeappweb(query):
speak("Closing, sir")
# Define a function to close multiple tabs
def close_tabs(num_tabs):
for _ in range(num_tabs):
pyautogui.hotkey("ctrl", "w")
sleep(0.5)
if "one tab" in query or "1 tab" in query:
close_tabs(1)
speak("One tab closed")
elif "2 tab" in query or "two tabs" in query:
close_tabs(2)
speak("Two tabs closed")
elif "3 tab" in query or "three tabs" in query:
close_tabs(3)
speak("Three tabs closed")
elif "4 tab" in query or "four tabs" in query:
close_tabs(4)
speak("Four tabs closed")
elif "5 tab" in query or "five tabs" in query:
close_tabs(5)
speak("Five tabs closed")
else:
keys = list(dictapp.keys())
for app in keys:
if app in query:
os.system(f"taskkill /f /im {dictapp[app]}.exe")
speak(f"{app} closed")