forked from PRAteek-singHWY/hackoctoberfest2024
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication Launcher.py
More file actions
56 lines (50 loc) Β· 2.12 KB
/
Application Launcher.py
File metadata and controls
56 lines (50 loc) Β· 2.12 KB
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
import subprocess
import platform
def open_application(app_name):
try:
if platform.system() == "Windows":
if app_name == "notepad":
subprocess.Popen(["notepad.exe"])
elif app_name == "calculator":
subprocess.Popen(["calc.exe"])
elif app_name == "chrome":
subprocess.Popen(["C:/Program Files/Google/Chrome/Application/chrome.exe"]) # Chrome path
else:
print("Application not configured.")
elif platform.system() == "Linux":
if app_name == "gedit":
subprocess.Popen(["gedit"])
elif app_name == "firefox":
subprocess.Popen(["firefox"])
else:
print("Application not configured.")
elif platform.system() == "Darwin": # For macOS
if app_name == "safari":
subprocess.Popen(["/Applications/Safari.app/Contents/MacOS/Safari"])
elif app_name == "textedit":
subprocess.Popen(["open", "-a", "TextEdit"])
else:
print("Application not configured.")
else:
print("Unsupported OS")
except Exception as e:
print(f"Failed to open {app_name}: {e}")
def main():
print("Select an application to open:")
print("1. Notepad (Windows) / Gedit (Linux) / TextEdit (macOS)")
print("2. Calculator (Windows)")
print("3. Chrome (Windows) / Firefox (Linux)")
print("4. Safari (macOS)")
choice = input("Enter the number of the application you want to open: ")
if choice == "1":
open_application("notepad" if platform.system() == "Windows" else "gedit" if platform.system() == "Linux" else "textedit")
elif choice == "2" and platform.system() == "Windows":
open_application("calculator")
elif choice == "3":
open_application("chrome" if platform.system() == "Windows" else "firefox")
elif choice == "4" and platform.system() == "Darwin":
open_application("safari")
else:
print("Invalid choice or application not supported on your OS.")
if __name__ == "__main__":
main()