Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Menu Driven Python program for opening the required software Application

  • Last Updated : 11 Aug, 2021

In this article, we will create a menu-driven Python program which will execute the required user tool when user will give the input as a text.

We can interact to OS through GUI (graphical user interface) and CLI (command line interface). We can also give the instructions to OS through programming language. In this program, you can instruct to OS using Python. This program gives the idea of how can we make a rule-based ChatBot.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

In this program, we will use os.system() method of OS module. This method executes the command (a string) in a subshell.

Syntax: os.system(command)

Return : On Unix, the return value is the exit status of the process and on Windows, the return value is the value returned by the system shell after running command.

Let’s see the implementation: 


# import os library
import os
# infinite while loop
while True:
    print("Hello! user choose your tool")
    print("Choose your tool :-\n")
    print("-> mousepad")
    print("-> chrome")
    print("-> vlc")
    print("-> virtualbox")
    print("-> camera")
    print("-> telegram")
    print("-> firefox")
    print("-> codeblocks")
    print("-> screenshot")
    print("-> task-manager")
    print("-> libreoffice impress / presentation")
    print("-> libreoffice writer / text editor / notepad")
    print("-> libreoffice clac / spreadsheets")
    print("-> libreoffice")
    print("-> jupyter notebook\n")
    print("chat with system:-",end=' ')
    # take input from user
    p = input()
    # check conditions
    if (("do not" in p) or ("dont" in p) or ("don't" in p)):
        print("OK user\n")
    elif (("open" in p) or ("start" in p) or ("run" in p) or ("execute" in p) or ("launch" in p) or ("activate" in p)):
        if (("mousepad" in p) or ("editor" in p)):
            # run mention application
        elif (("vlc" in p) or ("media player" in p)):
        elif (("virtualbox" in p) or ("virtual machine" in p) or ("virtual tool" in p)):
        elif (("camera" in p) or ("cheese" in p)):
        elif ("telegram" in p):
        elif ("codeblocks" in p):
        elif ("taskmanager" in p):
        elif ("screenshot" in p):
        elif (("jupyter" in p) or ("notebook" in p)):
            os.system("jupyter notebook")
        elif (("libreoffice impress" in p) or ("presentation tool" in p)):
            os.system("libreoffice --impress")
        elif (("libreoffice writer" in p) or ("text editor" in p)):
            os.system("libreoffice --writer")
        elif ("notepad" in p):
        elif (("libreoffice calc" in p) or ("spreadsheet" in p)):
            os.system("libreoffice --calc")
        elif ("libreoffice" in p):
        elif ("chrome" in p):
        elif (("firefox" in p) or ("mozilla" in p)):
        else :
            print("don't support")
    # terminating infinite while loop
    elif (("quit" in p) or ("exit" in p) or ("stop" in p) or ("close" in p) or ("deactivate" in p) or ("terminate" in p)):
        print("Thnank You!")
    else :
        print("don't support")


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!