SimpleSam commited on
Commit
6b33af6
·
verified ·
1 Parent(s): cf2b855

Create run_apps.py

Browse files
Files changed (1) hide show
  1. tools/run_apps.py +37 -0
tools/run_apps.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
+
4
+ def open_application(app_name):
5
+ """
6
+ Opens common Windows applications based on a user-friendly name.
7
+ """
8
+ # Dictionary mapping friendly names to Windows execution commands
9
+ apps = {
10
+ "word": "winword",
11
+ "powerpoint": "powerpnt",
12
+ "excel": "excel",
13
+ "notepad": "notepad",
14
+ "calculator": "calc",
15
+ "browser": "start msedge" # Opens Microsoft Edge
16
+ }
17
+
18
+ # Normalize the input name
19
+ target = app_name.lower().strip()
20
+
21
+ if target in apps:
22
+ print(f"Opening {app_name.capitalize()}...")
23
+ try:
24
+ # shell=True allows running system aliases like 'winword' or 'calc'
25
+ subprocess.Popen(apps[target], shell=True)
26
+ print("✅ Application launched successfully.")
27
+ except Exception as e:
28
+ print(f"❌ Failed to open application: {e}")
29
+ else:
30
+ print(f"❌ '{app_name}' is not in the configured list.")
31
+
32
+ # Example Usage
33
+ if __name__ == "__main__":
34
+ # Change this to "powerpoint", "excel", "notepad", or "calculator"
35
+ app_to_open = "word"
36
+
37
+ open_application(app_to_open)