import subprocess import os def open_application(app_name): """ Opens common Windows applications based on a user-friendly name. """ # Dictionary mapping friendly names to Windows execution commands apps = { "word": "winword", "powerpoint": "powerpnt", "excel": "excel", "notepad": "notepad", "calculator": "calc", "browser": "start msedge" # Opens Microsoft Edge } # Normalize the input name target = app_name.lower().strip() if target in apps: print(f"Opening {app_name.capitalize()}...") try: # shell=True allows running system aliases like 'winword' or 'calc' subprocess.Popen(apps[target], shell=True) print("✅ Application launched successfully.") except Exception as e: print(f"❌ Failed to open application: {e}") else: print(f"❌ '{app_name}' is not in the configured list.") # Example Usage if __name__ == "__main__": # Change this to "powerpoint", "excel", "notepad", or "calculator" app_to_open = "word" open_application(app_to_open)