def main():
        #while True:
        co.activatesystemcommandset()
        #google speech to text recognition
        command = sp.gstt()
        #tts.say('give your command')
        #time.sleep(5)
        #command = 'msword khole'
        tts.say(command)
        if command:
            #analize given command
            command = al.analize(command)
            print(command)
            if command == "open msword" or command == 'msword khole':
                tts.say('msword opened successfully')
                wordmain.main()
            elif command == "start mousehover" or command == 'mousehover khole':
                mousehover.main()
            elif command == "stop mousehover" or command == 'mousehover band karo':
                mousehover.stop_mousehover()
            elif command == "open chrome" or command == 'chrome kholo':
                ChromeMain.main()
            elif command == "find file" or command == 'file khojo':
                fs.type()
            elif command == "send mail":
                gmail2.gmailer()

            #elif command == "exit" or command == 'smapat karo':
            #break

        else:
            tts.say('Check settings again')
            print('Check settings again')
def wordcommander():
    while True:
        command = sp.gstt()
        #tts.say('give your command')
        #time.sleep(4)
        #command = 'likho'

        if command:
            command = al.analize(command)
            if command:
                try:
                    #print(command)
                    if command == 'close msword' or command == 'msword band karo':
                        tts.say('msword closed successfully')
                        break

                    elif command == "read" or command == 'padho':
                        with keyboard.pressed(Key.ctrl):
                            keyboard.press('a')
                            keyboard.release('a')
                        with keyboard.pressed(Key.alt):
                            keyboard.press('s')
                            keyboard.release('s')

                    elif command == "write" or command == 'likho':
                        writing.write()

                    #tts.say('give your command')
                    #time.sleep(4)
                    #command = 'msword band karo'

                    elif len(bc.mswordcommandsdict[command]) is 1:
                        operate.output1(bc.mswordcommandsdict[command][0])

                    elif len(bc.mswordcommandsdict[command]) is 2:
                        operate.output2(bc.mswordcommandsdict[command][0],bc.mswordcommandsdict[command][1])

                    elif len(bc.mswordcommandsdict[command]) is 3 :
                        operate.output3(bc.mswordcommandsdict[command][0],bc.mswordcommandsdict[command][1],bc.mswordcommandsdict[command][2])

                    time.sleep(1)

                except ValueError:
                    print('ValueError: key is a string, but its length is not 1')
                    tts.say('ValueError: key is a string, but its length is not 1')

            else:
                print('analizer doesnot work, Check its settings')
                tts.say('analizer doesnot work, Check its settings')
        else:
            print('error in google speech recognition')
            tts.say('error in google speech recognition')
    #stop msword
    stopword()
def chromecommander():
    while True:
        command = sp.gstt()
        if command:
            command = al.analize(command)
            if command:
                try:
                    print(command)

                    if command == "write" or command == 'likho':
                        chromelib.write()
                    elif command == "quit chrome" or command == 'chrome band karo':
                        tts.say('chrome closed successfully')
                        with keyboard.pressed(Key.ctrl):
                            with keyboard.pressed(Key.shift):
                                keyboard.press('q')
                                keyboard.release('q')
                        break
                    elif command == 'start mousehover' or command == 'mousehover shuru karo':
                        mousehover.main()
                    elif (command == 'stop mousehover'
                          ) or command == 'mousehover band karo':
                        mousehover.stop_mousehover()
                    elif command == "go" or command == 'khojo':
                        keyboard.press(Key.enter)
                        keyboard.release(Key.enter)
                        tts.say('page loaded successfully')

                    elif len(bc.browsercommandsdict[command]) is 2:
                        operate.output2(bc.browsercommandsdict[command][0],
                                        bc.browsercommandsdict[command][1])

                    elif len(bc.browsercommandsdict[command]) is 3:
                        operate.output3(bc.browsercommandsdict[command][0],
                                        bc.browsercommandsdict[command][1],
                                        bc.browsercommandsdict[command][2])

                    time.sleep(1)

                except ValueError:
                    print(
                        'ValueError: key is a string, but its length is not 1')
                    tts.say(
                        'ValueError: key is a string, but its length is not 1')

            else:
                print('analizer doesnot work, Check its settings')
                tts.say('analizer doesnot work, Check its settings')
        else:
            print('error in google speech recognition')
            tts.say('error in google speech recognition')
def mainloop():
    if internet_on():
        #activate system commandset
        co.activatesystemcommandset()
        command = sp.gstt()
        if command:
            command = al.analize(command)
            if command:
                #print(command)
                status = commander.main(command)
                if (status == -1):
                    return -1
            else:
                mainloop()
        else:
            tts.say('Check settings again')
            print('Check settings again')

    else:
        raise Exception('check internet connection and try again')
def chromecommander():
    while True:
        command = sp.gstt()
        if command:
            command = al.analize(command)
            if command:
                try:
                    print(command)

                    if (command == "write"):
                        chromelib.write()

                    elif (command == "open new window"):
                        chromelib.OpenNewWindow()

                    elif (command == "open new incognito window"):
                        chromelib.OpenNewIncognitoWindow()

                    elif (command == "open new tab"):
                        chromelib.OpenNewTab()

                    elif (command == "reopen last closed tab"):
                        chromelib.ReopenLastClosedTab()

                    elif (command == "jump to next open tab"):
                        chromelib.JumpToNextOpenTab()

                    elif (command == "jump to previous open tab"):
                        chromelib.JumpToPreviousOpenTab()

                    elif (command == "minimize current window"):
                        chromelib.MinimizeCurrentWindow()

                    elif (command == "close current window"):
                        chromelib.CloseCurrentWindow()

                    elif (command == "close current tab"):
                        chromelib.CloseCurrentTab()

                    elif (command == "quit chrome"):
                        chromelib.QuitChrome()
                        break

                    elif (command == "stop loading page"):
                        chromelib.StopLoadingPage()

                    elif (command == "print current page"):
                        chromelib.PrintCurrentPage()

                    elif (command == "save current page"):
                        chromelib.SaveCurrentPage()

                    elif (command == "reload current page"):
                        chromelib.ReloadCurrentPage()

                    elif (command == "everything on page bigger"):
                        chromelib.EverythingOnPageBigger()

                    elif (command == "everything on page smaller"):
                        chromelib.EverythingOnPageSmaller()

                    elif (command == "everything on page of default size"):
                        chromelib.EverythingOnPageDefaultSize()

                    elif (command == "delete previous word"):
                        chromelib.DeletePreviousWord()

                    elif (command == "go to top of page"):
                        chromelib.GoToTopOfPage()

                    elif (command == "go to end of page"):
                        chromelib.GoToEndOfPage()

                    elif (command == "open chrome menu"):
                        chromelib.OpenChromeMenu()

                    elif (command == "open find bar"):
                        chromelib.OpenFindBar()

                    elif (command == "jump to next match of find bar search"):
                        chromelib.JumpToNextMatchOfFindBarsearch()

                    elif (command ==
                          "jump to previous match of find bar search"):
                        chromelib.JumpToPreviousMatchOfFindBarsearch()

                    elif (command == "clear browsing data option"):
                        chromelib.ClearBrowsingDataOption()

                    time.sleep(1)

                except ValueError:
                    print(
                        'ValueError: key is a string, but its length is not 1')
                    tts.say(
                        'ValueError: key is a string, but its length is not 1')

            else:
                print('analizer doesnot work, Check its settings')
                tts.say('analizer doesnot work, Check its settings')
        else:
            print('error in google speech recognition')
            tts.say('error in google speech recognition')
def wordcommander():
    while True:
        command = sp.gstt()
        if command:
            command = al.analize(command)
            if command:
                try:
                    print(command)
                    if(command == "read"):
                        wordlib.read()

                    elif(command == "write"):
                        wordlib.write()

                    elif(command == "save"):
                        wordlib.save()

                    elif(command == "select all"):
                        wordlib.select_all()

                    elif(command == "deselect"):
                        wordlib.deselect()

                    elif(command == "bold"):
                        boldActivator = True
                        wordlib.bold()

                    elif(command == "italic"):
                        italicActivator = True
                        wordlib.italic()

                    elif(command == "remove bold"):
                        if boldActivator is True:
                            wordlib.bold()
                            boldActivator = False

                    elif(command == "remove italic"):
                        if italicActivator is True:
                            wordlib.italic()
                            italicActivator = False

                    elif(command == "underline"):
                        underlineActivator = True
                        wordlib.underline()

                    elif(command == "remove underline"):
                        if underlineActivator is True:
                            wordlib.underline()
                            underlineActivator = False

                    elif(command == "close exit quit"):
                        wordlib.close()

                    elif(command == "copy"):
                        wordlib.copy()

                    elif(command == "paste"):
                        wordlib.paste()

                    elif(command == "decrease font size"):
                        wordlib.decrease_font_size()

                    elif(command == "increase font size"):
                        wordlib.increase_font_size()

                    elif(command == "cut text"):
                        wordlib.cut_text()

                    elif(command == "undo"):
                        wordlib.undo()

                    elif(command == "redo"):
                        wordlib.redo()

                    elif(command == "left align text"):
                        wordlib.left_align_text()

                    elif(command == "right align text"):
                        wordlib.right_align_text()

                    elif(command == "create new document"):
                        wordlib.create_new_document()

                    elif(command == "split document window"):
                        if(splitDocumentWindowActivator == False):
                            splitDocumentWindowActivator = True
                            wordlib.split_document_window()
                        else:
                            tts.say('split document window is already activated')

                    elif(command == "remove split document window"):
                        if(splitDocumentWindowActivator == True):
                            wordlib.split_document_window()

                    elif(command == "print document"):
                        wordlib.print_document()

                    elif(command == "double underline"):
                        if (doubleUnderlineActivator == False):
                            doubleUnderlineActivator = True
                            wordlib.double_underline()
                        else:
                            tts.say('double underline is already activated')

                    elif(command == "remove double underline"):
                        if doubleUnderlineActivator is True:
                            wordlib.double_underline()
                            underlineActivator = False

                    elif(command == "apply subscript"):
                        if (subscriptActivator == False):
                            subscriptActivator = True
                            wordlib.subscript()
                        else:
                            tts.say('subscript is already activated')

                    elif(command == "remove subscript"):
                        if subscriptActivator is True:
                            wordlib.subscript()
                            subscriptActivator = False

                    elif(command == "apply superscript"):
                        if (superscriptActivator == False):
                            superscriptActivator = True
                            wordlib.superscript()
                        else:
                            tts.say('superscript is already activated')

                    elif(command == "remove superscript"):
                        if superscriptActivator is True:
                            wordlib.superscript()
                            superscriptActivator = False

                    elif(command == "one character right"):
                        wordlib.one_char_right()

                    elif(command == "one character left"):
                        wordlib.one_char_left()

                    elif(command == "one word left"):
                        wordlib.one_word_left()

                    elif(command == "one word right"):
                        wordlib.one_word_right()

                    elif(command == "one paragraph up"):
                        wordlib.one_para_up()

                    elif(command == "one paragraph down"):
                        wordlib.one_para_down()

                    elif(command == "one line up"):
                        wordlib.one_line_up()

                    elif(command == "one line down"):
                        wordlib.one_line_down()

                    elif(command == "go to end of line"):
                        wordlib.end_of_line()

                    elif(command == "go to beginning of line"):
                        wordlib.beg_of_line()

                    elif(command == "go to end of document"):
                        wordlib.end_of_document()

                    elif(command == "go to beginning of document"):
                        wordlib.beg_of_document()

                    elif(command == "delete one left character"):
                        wordlib.delete_one_char_left()

                    elif(command == "delete one right character"):
                        wordlib.delete_one_char_right()

                    elif(command == "delete one left word"):
                        wordlib.delete_one_word_left()

                    elif(command == "delete one right word"):
                        wordlib.delete_one_word_right()

                    elif(command == 'close msword'):
                        break
                except ValueError:
                    print('ValueError: key is a string, but its length is not 1')
                    tts.say('ValueError: key is a string, but its length is not 1')

            else:
                print('analizer doesnot work, Check its settings')
                tts.say('analizer doesnot work, Check its settings')
        else:
            print('error in google speech recognition')
            tts.say('error in google speech recognition')
    #stop msword
    stopword()