-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps.py
38 lines (30 loc) · 1.5 KB
/
apps.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
import os
from speak_listen import speak
from speak_listen import TakeCommand
def open_system_app(query):
dictapp = {"command prompt":"cmd","commandprompt":"cmd","paint":"mspaint","word":"winword","excel":"excel","chrome":"chrome","vs code":"code","vscode":"code","powerpoint":"powerpnt" , "notepad":"notepad" , "Microsoft Edge":"msedge"}
keys = list(dictapp.keys())
try:
query = query.replace("open","")
for app in keys:
if app in query:
speak(f"Opening {app}")
os.system(f"start {dictapp[app]}")
except Exception as e:
speak(f"Failed to open {app}. Error: {str(e)}")
def close_system_app(query):
dictapp = {"command prompt":"cmd","commandprompt":"cmd","paint":"mspaint","word":"winword","excel":"excel","chrome":"chrome","vscode":"code","powerpoint":"powerpnt" , "youtube" :"msedge" , "google" : "msedge" , "notepad":"notepad", "Microsoft edge":"msedge" , "edge":"msedge", "youtube":"msedge"}
keys = list(dictapp.keys())
try:
query = query.replace("close","")
for app in keys:
if app in query:
os.system(f"taskkill /f /im {dictapp[app]}.exe") #add .exe if error
speak(f"Closing {app}")
except Exception as e:
speak(f"Failed to close {app}. Error: {str(e)}")
# Example usage
# To open Notepad on Windows
# open_system_app("notepad.exe")
# To close Notepad on Windows
# close_system_app("notepad.exe")