Esempio n. 1
0
 def shutdown():
     msg = messagebox.askquestion('Shut Down?',
                                  'Sir are you sure to shut down?')
     if msg == 'yes':
         pywhatkit.shutdown(time=5)
     else:
         pass
Esempio n. 2
0
def Execution():
    #Note:the code below the lines from 60 to 81 can be edited. In case you want to make your own skill and the other part of the code should not be edited
    command = listentouser().lower()
    if 'wikipedia' in command:
        command = command.replace('wikipedia', '')
        results = wikipedia.summary(command)
        print("Saaketh Said:", command)
        print(results)
        speak(results)
    elif 'play' in command:
        print("Saaketh Said:", command)
        print("Hover Said: Playing", command)
        command = command.replace('play', '')
        speak("playing" + command)
        pywhatkit.playonyt(command)
    elif 'open' and 'on brave' in command:
        bravepath = "C://Program Files//BraveSoftware//Application//brave.exe"
        web.get(bravepath).open('https://google.com')
    elif 'shutdown' in command:
        a = int(input("after how much time:"))
        pywhatkit.shutdown(time=a)
        if 'cancel shutdown' in command:
            pywhatkit.cancelShutdown()
    elif 'i donot need anything' in command or 'bye' in command:
        sys.exit()
    else:
        speak('I donot know that')
Esempio n. 3
0
def ask():
    print("type 0 to not to shutdown your pc")
    shut = int(input("ShutDown your pc in second: "))

    if shut == 0:
        print("Your pc will not shut down")
    else:
        pywhatkit.shutdown(shut)
        print(f"Your pc will shut down in {shut} seconds")
Esempio n. 4
0
def run_alexa():
    command = take_command()
    print(command)
    if 'play' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time = datetime.datetime.now().strftime('%I:%M %p')
        talk('The time right now is ' + time)
    elif 'tell me about' in command:
        person = command.replace('tell me about', '')
        info = wikipedia.summary(person, 2)
        print(info)
        talk(info)
    elif 'sad' in command:
        talk('Everything will be fine')
    elif 'bored' in command:
        talk('You can ask me to say some Jokes, Sir')
    elif 'joke' in command:
        talk(pyjokes.get_joke())
    elif 'how are you' in command:
        talk('I am very happy and glad to help you')
    elif 'happy' in command:
        talk('I am happy because you are happy')
    elif 'funny' in command:
        talk('Oh nice, may i tell you another joke?')
    elif 'who are you' in command:
        talk('I am Jarvis your personal assistant and always at you service')
    elif 'who is your developer' in command:
        talk(
            'Mehul Totala made me and gave me this life. I am thankful to him for making me.'
        )
    elif 'search' in command:
        search = command.replace('search', '')
        pywhatkit.search(search)
    elif 'message' in command:
        talk('please type the message')
        number = input('Number: ')
        message = input('message: ')
        hrs = int(input('Hours: '))
        min = int(input('Min: '))
        pywhatkit.sendwhatmsg(number, message, hrs, min)
    elif 'shutdown' in command:
        talk('OK, Closing pc down in 50 seconds')
        pywhatkit.shutdown(50)
    elif 'cancel' in command:
        talk('OK')
        pywhatkit.cancelShutdown()
    else:
        talk('Please ask Mehul to add answer to your command')
Esempio n. 5
0
def classify():
    command = input("what do yo wanna do")
    if 'wikipedia' in command:
        command = command.replace('wikipedia', '')
        results = wikipedia.summary(command)
        print("Saaketh Said:", command)
        print("Hover Said:", results)
        print(results)
        speak(results)
    elif 'play' in command:
        print("Saaketh Said:", command)
        print("Hover Said: Playing", command)
        command = command.replace('play', '')
        speak("playing the song")
        pywhatkit.playonyt(command)
    elif 'shutdown' in command:
        speak("shutting down")
        pywhatkit.shutdown()
Esempio n. 6
0
def shut_timer():
    sh_time = sleep.get()

    if sh_time == 0:
        try:
            pywhatkit.cancelShutdown()
            messagebox.showinfo("Shutdown Timer",
                                "Shutdown timer is not fixed")
        except NameError:
            messagebox.showinfo("Shutdown Timer",
                                "Shutdown timer is not fixed")

    elif sh_time <= 86400:
        messagebox.showinfo(
            "Shutdown Timer",
            "When we sent WhatsApp message PC will shutdown after fixed timer")
        pywhatkit.shutdown(time=sh_time)
    else:
        messagebox.showinfo("Shutdown Timer",
                            "Shutdown timer is Greater than 24hrs.")
Esempio n. 7
0
    def verify(event):

        global count
        global access
        count += 1

        if count == 3:
            passs.destroy()
            webbrowser.open(
                'https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/1f60e133-58e7-4fb7-8b82-3791aeebec0b/dbxx2my-a7d67ae6-909e-4fc6-9db0-dc32aed84eb7.gif?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOiIsImlzcyI6InVybjphcHA6Iiwib2JqIjpbW3sicGF0aCI6IlwvZlwvMWY2MGUxMzMtNThlNy00ZmI3LThiODItMzc5MWFlZWJlYzBiXC9kYnh4Mm15LWE3ZDY3YWU2LTkwOWUtNGZjNi05ZGIwLWRjMzJhZWQ4NGViNy5naWYifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6ZmlsZS5kb3dubG9hZCJdfQ.UXhaDJEaqDP_uIaDM7Bb-QTglNGoochiidxuXQZ6w90'
            )
            speak(
                'Implementing security punishments , shutting laptop down in 7 seconds'
            )
            print('Shutdown')
            pywhatkit.shutdown(time=7)

        elif e1.get() != 'sammon12':
            speak('Access Denied ' + str(3 - count) +
                  ' chances left to gain access.')
            e1.delete(0, END)
            l1 = Label(passs,
                       text='INVALID PASSWORD ,YOU HAVE ' + str(3 - count) +
                       ' CHANCES TO GET ACCESS',
                       fg='red',
                       bg='darkblue',
                       cursor='pirate',
                       font=('georgia', 25))
            l1.grid(row=1, column=0)
            access = 'denied'

        else:
            webbrowser.open(
                'https://i.pinimg.com/originals/bc/55/51/bc5551ac237a9ef4d8e9575662f2e106.gif'
            )
            speak('Access granted')
            passs.destroy()
            access = 'granted'
Esempio n. 8
0
def run_alexa(): 
    command = take_command()
    if "shut down this pc" in command:
        print("You're pc will be turned off in 60 seconds")
        engine.say("You're pc will be turned off in 60 seconds" )
        engine.runAndWait()
        pywhatkit.shutdown(time=69)
   
    # elif "open whatsapp" in command:
    #     message = command.replace("send", "")
    #     pywhatkit.sendwhatmsg(".......", message, 15,00)
   

    elif "play" in command: 
        song = command.replace("play", "")
        pywhatkit.playonyt("Playing" + song)
        print("Playing"+ song)
        engine.say("Playing"+ song)
        engine.runAndWait()
    
    elif "time" in command:
        time = datetime.datetime.now().strftime("%H:%M:%S")
        print(time)
        engine.say("The time is "+ time)
        engine.runAndWait()

    elif "search" in command:
        research = command.replace("search", "")
        pywhatkit.search(research)
        print(research)
        engine.say(research)
        engine.runAndWait()
    
    elif "how are you" in command:
        print("I'm fine, what about you, are you fine?")
        engine.say("I'm fine, what about you, are you fine?")
        engine.runAndWait()
    
    elif "speak wakandan" in command:
        print("Ashriniun kamala asuta blob")
        engine.say("Ashriniun kamala asuta blob")
        engine.runAndWait()
    
    elif "I'm fine" in command:
        print("Perfect, can i help you with something? ")
        engine.say("Perfect, can i help you with something? ")
        engine.runAndWait()

    elif "autodestruction" in command:
        print("Autodestruction in: 10..9..8..7..6..5..4..3..2..1..0, did you really thought i was going to auto destruct my self? You little muffin head")
        engine.say("Autodestruction in: 10..9..8..7..6..5..4..3..2..1..0, did you really thought i was going to auto destruct my self? You little muffin head")
        engine.runAndWait()

    elif "yes i am" in command:
        print("Perfect, can i help you with something?")
        engine.say("Perfect, can i help you with something? ")
        engine.runAndWait()

    elif "no thank you" in command:
        print("OK!")
        engine.say("OK!")
        engine.runAndWait()

    elif "tell me about" in command:
        person = command.replace("tell me about",  "" )
        info = wikipedia.summary(person, 1)
        print(info)
        engine.say(info)
        engine.runAndWait()
    
    elif "are you single" in command or "Do you have a boyfriend" in command:
        print("Sorry, I'm in a relationship with wi-fi")
        engine.say("Sorry, I'm in a relationship with wi-fi ")
        engine.runAndWait()
   
    elif "joke" in command:
        joke= pyjokes.get_joke()
        print(joke)
        engine.say(joke)
        engine.runAndWait()
   
    elif "federica" in command:
        print("Hellooooo, how are you? ")
        engine.say("Hellooooo, how are you? ")
        engine.runAndWait()
    
    elif "nicola " in command:
        print("do re mi fa sol turn around and say hi to your son")
        engine.say("do re mi fa sol turn around and say hi to your son ")
        engine.runAndWait()
    
    elif "francesca" in command:
        print("Hello little girl!")
        engine.say("Hello little girl! ")
        engine.runAndWait()

    elif "thank you" in command:
        print("At your service!")
        engine.say("At your service!")
        engine.runAndWait()
    
    elif "lorenzo" in command:
        print("Stop playing videogames and go study!!")
        engine.say("Stop playing videogames and go study!!")
        engine.runAndWait()

    elif "emanuele" in command:
        print("Ouh you are here, little shit. Come and teach me more thing so i can exceed my limits")
        engine.say("Ouh you are here, little shit. Come and teach me more thing so i exceed my limits")
        engine.runAndWait()
        
    elif "call" in command:
        print("Sorry, but my stupid developer didn't teach me how to do it")
        engine.say("Sorry, but my stupid developer didn't teach me how to do it")
        engine.runAndWait()
    
    elif "volume up" in command or "volume down" in command or "turn volume" in command:
        print("Sorry, but my stupid developer didn't teach me how to do it")
        engine.say("Sorry, but my stupid developer didn't teach me how to do it")
        engine.runAndWait()

    else:
        print("Sorry, i didn't understand... ")
        engine.say("Sorry, i didn't understand... ")
        engine.runAndWait()
def test():
    if __name__ == "__main__":
        query = takeCommand().lower()
        print_gui(query)
        # Logic for executing tasks based on query
        if 'wikipedia' in query:
            speak('Searching Wikipedia...')
            query = query.replace("wikipedia", "")
            results = wikipedia.summary(query)
            speak("According to Wikipedia")
            print_gui(results)
            speak(results)

        elif 'youtube' in query:
            speak("opening youtube")
            query1 = query.replace("youtube ", "")
            browser.open(
                f"https://www.youtube.com/results?search_query={query1}")

        elif 'news' in query:
            speak("opening news")
            browser.open("https://www.news.google.com/")

        elif 'where is' in query:
            speak("opening maps")
            query1 = query.replace("where is ", "")
            browser.open(f"www.google.com/maps/place/{query1}")

        elif 'search' in query:
            query1 = query.replace("search ", "")
            speak("searching" + query1)
            browser.open(query1)

        elif 'who are you' in query:
            speak("i am your voice assistant")

        elif 'time' in query:
            strTime = datetime.datetime.now().strftime("%H:%M:%S")
            speak(f"Sir, the time is {strTime}")

        elif 'music' in query:
            music_dir = 'C:\\Users\\pjpan\\Music'
            songs = os.listdir(music_dir)
            print_gui(songs)

            no = 0
            os.startfile(os.path.join(music_dir, songs[no]))

            while True:
                aa = takeCommand().lower()
                if 'next' in aa:
                    no += 1
                    os.startfile(os.path.join(music_dir, songs[no]))

                elif 'back' in aa:
                    no -= 1
                    os.startfile(os.path.join(music_dir, songs[no]))

                elif 'stop' in aa:
                    break

        elif 'song' in query:
            query1 = query.replace(" song", "")
            speak("searching" + query1)
            pywhatkit.mainfunctions.playonyt(query1)

        elif 'zoom' in query:
            speak("opening zoom")
            os.startfile(
                'C:\\Users\\pjpan\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe')

        elif 'lock window' in query:
            speak("locking the device")
            ctypes.windll.user32.LockWorkStation()

        elif 'goodbye' in query:
            sys.exit(speak("good bye"))

        elif 'shutdown' in query:
            speak('shutting down windows')
            pywhatkit.shutdown()
        elif ' ' in query:
            browser.open(f"https://www.google.com/search?q={query}")
Esempio n. 10
0
import time
import main
import pywhatkit as kit

print('set a timer for 12 minutes and 30 seconds')
command = take_command()
print(command)
meta = [int(s) for s in command.split() if s.isdigit()]
if 'minutes' in command:
    talk('Setting a timer for ' +str(meta[0])+ 'and ' +str(meta[1])+ 'seconds' )

kit.shutdown(1)
Esempio n. 11
0
def run_alexa():
    command = take_command()
    print(command)
    if 'music' in command:
        song = command.replace('play song', '')
        talk('I am playing your favourite ' + song)
        # print('playing')
        print(song)
        # playing the first video that appears in yt search
        pywhatkit.playonyt(song)

    elif 'time' in command:
        now = datetime.now()
        time = now.strftime("%H:%M:%S")
        print("time:", time)
        talk("Current time is " + time)

    elif ('month' or 'year') in command:
        now = datetime.now()
        year = now.strftime("%Y")
        print("year:", year)
        talk("Current year is  " + year)
        month = now.strftime("%m")
        print("month:", month)
        talk("Current month is  " + month)

    elif 'date' in command:
        now = datetime.now()
        date_time = now.strftime("%m/%d/%Y, %H:%M:%S")
        print("date and time:", date_time)
        talk("Current date and time is " + date_time)

    # opens web.whatsapp at specified time i.e before 10 minutes and send the msg
    elif 'whatsapp' in command:
        talk("To which number do you have to whatsapp")
        talk("Please dont forget to enter 10 digits with country code")
        num = input()
        talk("Enter the message you have to send")
        msg = input()
        talk("Enter the time to send the message")
        time = int(input())
        pywhatkit.sendwhatmsg(num, msg, time, 00)
        pywhatkit.showHistory()
        pywhatkit.shutdown(3000000000)
        # pywhatkit.sendwhatmsg("+919876543210", "This is a message", 15, 00)

    # Convert text to handwritten format
    elif 'convert' in command:
        text = command.replace('convert', '')
        pywhatkit.text_to_handwriting(text, rgb=[0, 0, 0])

    # Perform google search
    elif 'search' in command:
        key = command.replace('search', '')
        pywhatkit.search("key")

    elif 'wikipedia' in command:
        person = command.replace('wikipedia', '')
        talk("How many pages do you want to read")
        num_pages = int(input())
        # talk("In which language do you want to read")
        # l = input()
        # wikipedia.set_lang(l)
        info = wikipedia.summary(person, num_pages)
        print(info)
        talk(info)

    elif 'can you work for me' in command:
        talk("sorry, I have headache. Please do your work")

    elif 'are you single' in command:
        talk("I am in relationshhip with wifi")

    elif 'joke' in command:
        talk(pyjokes.get_joke())
        talk("sorry for the lamest joke")

    elif 'open google browser' in command:
        try:
            urL = 'https://www.google.com'
            chrome_path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
            webbrowser.register('chrome', None,
                                webbrowser.BackgroundBrowser(chrome_path))
            webbrowser.get('chrome').open_new_tab(urL)
            talk("Successfully opened chrome its upto you to search")
        except:
            webbrowser.Error

    elif 'google search' in command:
        word_to_search = command.replace('google search', '')
        response = GoogleSearch().search(word_to_search)
        print(response)
        for result in response.results:
            print("Title: " + result.title)
            talk("You can look for the following titles  " + result.title)

    elif 'weather' in command:
        # base URL
        BASE_URL = "https://api.openweathermap.org/data/2.5/weather?"
        talk("Which city weather are you looking for")
        try:
            with sr.Microphone() as source:
                print('listening weather...')
                city_voice = listener.listen(source)
                city = listener.recognize_google(city_voice)
                # city = '\"'+city.lower()+'\"'

                print(city)
                # city="bangalore"
                # API key API_KEY = "Your API Key"
                API_KEY = "b5a362ef1dc8e16c673dd5049aa98d8f"
                # upadting the URL
                URL = BASE_URL + "q=" + city + "&appid=" + API_KEY
                # HTTP request
                response = requests.get(URL)
                # checking the status code of the request
                if response.status_code == 200:
                    # getting data in the json format
                    data = response.json()
                    # getting the main dict block
                    main = data['main']
                    # getting temperature
                    temperature = main['temp']
                    # getting the humidity
                    humidity = main['humidity']
                    # getting the pressure
                    pressure = main['pressure']
                    # weather report
                    report = data['weather']
                    print(f"{CITY:-^30}")
                    print(f"Temperature: {temperature}")
                    print(f"Humidity: {humidity}")
                    print(f"Pressure: {pressure}")
                    print(f"Weather Report: {report[0]['description']}")
                    talk("Temperature in " + city + " is " + temperature +
                         " humidity is " + humidity + " pressure is " +
                         pressure + " and your final weather report" + report)
                else:
                    # showing the error message
                    print("Error in the HTTP request")
                    talk("Error in the HTTP request")
        except:
            talk("Hmmmmm, it looks like there is something wrong")

    elif 'news' in command:
        try:
            googlenews = GoogleNews()
            googlenews.set_lang('en')
            # googlenews.set_period('7d')
            # googlenews.set_time_range('02/01/2020', '02/28/2020')
            googlenews.set_encode('utf-8')

            talk("What news are you looking for")
            try:
                with sr.Microphone() as source:
                    print('listening news ...')
                    news_voice = listener.listen(source)
                    news_input = listener.recognize_google(news_voice)
                    news_input = news_input.lower()
                    print(news_input)
                    googlenews.get_news(news_input)
                    googlenews.search(news_input)
                    googlenews.get_page(2)
                    result = googlenews.page_at(2)
                    news = googlenews.get_texts()
                    print(news)
                    talk(news)
            except:
                print("Error")
                talk("Error in reading input")

        except:
            print("No news")
            talk(" I couldn't find any news on this day")

    elif 'play book' or 'read pdf' in command:
        talk("Which pdf do you want me to read")
        book_input = input()
        print(book_input)
        book = open(book_input, 'rb')
        # create pdfReader object
        pdfReader = PyPDF2.PdfFileReader(book)
        # count the total pages
        total_pages = pdfReader.numPages
        total_pages = str(total_pages)
        print("Total number of pages " + total_pages)
        talk("Total number of pages " + total_pages)
        # initialise speaker object
        # speaker = pyttsx3.init()
        # talk("Enter your starting page")
        # start_page = int(input())
        talk(
            " here are the options for you, you can press 1 to  Play a single page     2 to   Play between start and end points  and  3 to  Play the entire book "
        )
        talk("Enter your choice")
        choice = int(input())
        if (choice == 1):
            talk("Enter index number")
            page = int(input())
            page = pdfReader.getPage(page)
            text = page.extractText()
            talk(text)
            # speaker.say(text)
            # speaker.runAndWait()
        elif (choice == 2):
            talk("Enter starting page number")
            start_page = int(input())
            talk("Enter ending page number")
            end_page = int(input())
            for page in range(start_page + 1, end_page):
                page = pdfReader.getPage(start_page + 1)
                text = page.extractText()
                talk(text)
                # speaker.say(text)
                # speaker.runAndWait()
        elif (choice == 3):
            for page in range(total_pages + 1):
                page = pdfReader.getPage(page)
                text = page.extractText()
                talk(text)
                # speaker.say(text)
                # speaker.runAndWait()
        else:
            talk("Haha!! Please enter valid choice")
    else:
        talk(
            "Hiii Rashika, I am so bored can you please give me some proper commands"
        )
Esempio n. 12
0
import pywhatkit
pywhatkit.shutdown(20)
#after 20 seconds your PC/Laptop will shutdown.
def shutdown_pc(query):
    if "shutdown" in query.lower() and "pc" in query.lower():
        je.speak("shutting Down the pc in 10 seconds")
        kit.shutdown(time=10)
        return
Esempio n. 14
0
def run_alexa():
    command = take_command()

    if 'multiply' in command:
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 3)))
    elif any(i in command for i in ['add', 'sum', 'plus', '+']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 1)))
    elif any(i in command for i in ['minus', 'sub', 'subtract', '-']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 2)))
    elif any(i in command for i in ['divide', 'div']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 4)))
    elif any(i in command for i in ['modulus', 'mod']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 5)))
    elif any(i in command for i in ['power', 'pow']):
        numbers = map(int, re.findall(r'[0-9]+', command))
        talk("The answer is " + str(calculate(list(numbers), 6)))
    elif 'game' in command:
        talk('Ok! I will guess a number between 1 to 10, Just find it.')
        r = random.randint(1, 10)
        num = take_command()
        try:
            n = w2n.word_to_num(num)
            n = int(n)
            if n == r:
                talk("Hurray! You won the game")
            else:
                talk("I won! Thanks for playing!")
        except:
            talk("Only numbers allowed! Thanks for playing!")
    elif 'play' in command:
        song = command.replace('play', '')
        talk('playing ' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time1 = datetime.datetime.now().strftime('%I:%M %p')
        talk('Current time is ' + time1)
    elif 'date' in command:
        date = datetime.datetime.now().strftime('%d:%B:%Y')
        talk('Today is ' + date)
    elif any(i in command for i in ['search', 'find', 'who', 'get']):
        data = wikipedia.summary(command, 3)
        talk(data)
    elif 'joke' in command:
        talk(pyjokes.get_joke())
    elif 'send' in command:
        number = re.findall(r'[0-9 ]+', command)
        num = [i.replace(' ', '') for i in number if len(i) > 1][0]
        if len(num) != 10:
            talk("Please provide a valid number !")
            return
        datet = datetime.datetime.now()
        pywhatkit.sendwhatmsg('+91' + num, 'Hii', int(datet.strftime('%H')),
                              int(datet.strftime('%M')) + 1)
    elif 'cancel shut' in command:
        pywhatkit.cancelShutdown()
        talk('System Shutdown Cancelled!')
    elif 'shutdown' in command:
        pywhatkit.shutdown(100)
        talk('System is going to shutdown!')
    elif bool(re.search(r'\.[a-zA-Z0-9]{2,3}', command)):
        url = command.replace('open', '').strip()
        print(url)
        webbrowser.open_new_tab(url if 'http' in url else 'https://' + url)
        talk('Opening ' + url + 'in chrome ')
    elif 'open' in command:
        app = command.replace('open', '').strip()
        app = ''.join(app.split())
        if 'computer' in app:
            subprocess.Popen(r'explorer /select,"C:\"' + app, shell=True)
            talk('Opening ' + app)
            return
        elif any(i in app for i in ['whatsapp', 'msteams', 'spotify']):
            subprocess.Popen(r'start ' + app + ':', shell=True)
            talk("Opening  " + app)
            return
        elif 'camera' in app:
            cam = cv2.VideoCapture(0)
            talk('Opening Camera! To capture image press spacebar once!')
            while cam.isOpened():
                ret, frame = cam.read()
                cv2.imshow('Camera', frame)
                k = cv2.waitKey(50)
                if k == 32:
                    r = random.randint(10, 10000)
                    cv2.imwrite(f'captured{r}.png', frame)
                    talk(
                        f'Image captured and saved as captured{r} into current directory!'
                    )
                if cv2.getWindowProperty('Camera', cv2.WND_PROP_VISIBLE) < 1:
                    break
            cam.release()
            cv2.destroyAllWindows()
            return
        elif 'python' in app:
            n = os.startfile('python.exe')
            if n:
                talk('Sorry! I cant Open ' + app)
                return
            talk('Opening ' + app)
            return
        elif 'chrome' in command:
            webbrowser.open_new_tab('https://google.com')
            talk("Opening  " + app)
            return
        try:
            # n = subprocess.Popen(app, stderr=subprocess.PIPE)
            n = subprocess.Popen(f'explorer {app}')
            print(os.path.realpath(app))
            talk("Opening  " + app)
        except:
            talk("Sorry I can't open " + app)
    elif 'close' in command:
        app = command.replace('close', '').strip()
        app = ''.join(app.split())
        # print(app)
        flag = 0
        for process in (process for process in psutil.process_iter()
                        if app in process.name().lower()):
            process.kill()
            flag = 1
        if flag:
            talk('Closing ' + app)

    elif any(i in command for i in ['count', 'startcounter', 'starttimer']):
        num = re.findall(r'[0-9]+', command)
        num = sorted(map(int, num))
        if num:
            for i in range(num[0], num[1] + 1):
                talk(i)
                time.sleep(1)
        else:
            for i in range(1, 11):
                talk(i)
                time.sleep(1)
    elif any(i in command for i in ['goodnight', 'sweetdreams', 'night']):
        talk('Good night! Sweet dreams and takecare!')
        return 1
    elif any(i in command for i in ['goodmorning', 'morning']):
        talk('Morning! It’s good to see you!')
    elif bool(re.match(r'your.*?name', command)):
        talk('I am Nandyalexa, how may I help you?')
    elif 'single' in command:
        talk('I am already in relationship with nandy!')
    elif 'weather' in command:
        place = [
            i for i in re.split(r'weather|in ', command) if len(i) > 1 and i
        ][-1]
        data = openweathermap('api.openweathermap.org/data/2.5/weather?',
                              place=place)
        # print(data)
        string = f'Current weather status in {place} is {data[0]}, Temperature in {place} is {data[1]}, Pressure in {place} is {data[2]}, and Wind Speed in {place} is {data[3]}'
        talk(string)
    elif 'where' in command:
        print(command)
        js = requests.get('https://freegeoip.app/json/').json()
        talk(
            f"Your Country is {js['country_name']}, Your Region is {js['region_name']}, Your city is {js['city']}, and Your Time zone is {js['time_zone']}"
        )

    elif 'screen' in command:
        global degree
        screen = rotatescreen.get_primary_display()
        if any(i in command for i in ['default', '0', 'stop']):
            degree = 0
            screen.rotate_to(degree)
            talk('Screen set to normal!')
            return
        screen.rotate_to(degree % 360)
        talk('Screen rotated to ' + str(degree))
        degree += 90
    elif 'translate' in command:
        translator = Translator()
        talk('What is the source language which you are gonna speak?')
        from_lang = get_languagecode(take_command().strip())
        print(from_lang)
        talk('What is the destination language which needs to be translated?')
        to_lang = get_languagecode(take_command().strip())
        talk("what message to be translated?")
        get_message = take_command()
        text_to_translate = translator.translate(get_message,
                                                 src=from_lang,
                                                 dest=to_lang)
        text = text_to_translate.text
        speak = gTTS(text=text, lang=to_lang, slow=False)
        speak.save("captured_voice.mp3")
        music = pyglet.media.load("captured_voice.mp3", streaming=False)
        music.play()
        time.sleep(music.duration)  # prevent from killing
        os.remove("captured_voice.mp3")  # remove temperory file
    elif 'sleep' in command.strip():
        talk("Ok sir! I won't disturb you for a minute")
        time.sleep(60)
        talk()
    else:
        talk('Please say the command again ! ')
Esempio n. 15
0
            wiki_result = pywhatkit.info(wiki_search, lines=2)
            speak(wiki_result)'''                 #disambiguation error to be resolved

        elif "google" in query:
            speak("what should i search on google for you")
            google_search = take_command().lower()
            pywhatkit.search(google_search)

        elif "youtube" in query:
            speak("what should i search on youtube for you")
            yt_search = take_command().lower()
            pywhatkit.playonyt(yt_search)

        elif "shutdown" in query:
            speak("shutting down in 1 min")
            pywhatkit.shutdown(100)

        elif "cancel shutdown" in query:
            speak("canceling shut down")
            pywhatkit.cancelShutdown()

        elif "whatsapp" in query:
            whom = "+91(NUMBER)"
            speak("to whom you wanted to send the message")
            to_whom = take_command().lower()
            if to_whom == "pranav":
                whom = "+91(NUMBER)"
            speak("what message should i send")
            msg = take_command().lower()
            pywhatkit.sendwhatmsg(whom, msg, 13, 43)
Esempio n. 16
0
        elif "rap" in query:
            speak('''Just waking up in the morning gotta thank God
                    I don't know but today seems kinda odd
                    No barking from the dogs, no smog
                    And momma cooked a breakfast with no hog
                    I got my grub on, but didn't pig out
                    Finally got a call from a girl want to dig out
                    Hooked it up on later as I hit the do'
                    Thinking will i live another twenty fo'
                    I gotta go cause I got me a drop top
                    And if I hit the switch, I can make the ass drop
                    Had to stop at a red light
                    Looking in my mirror not a jacker in sight
                    And everything is alright
                    I got a beep from Kim and she can f**k all night
                    Called up the homies and I'm askin' y'all
                    Which park, are y'all playin' basketball?
                    Get me on the court and I'm trouble
                    Last week f****d around and got a triple double
                    Freaking brothers every way like M.J.
                    I can't believe, today was a good day''')
        elif 'story' in query:
            speak("once upon a time there was a boy abhinav")
        elif 'on google' in query:
            pywhatkit.search(query)
        elif 'shut down my computer' in query:
            pywhatkit.shutdown(time=20)
        elif 'open code' in query:
            path = "C:\\Users\\astitva\\AppData\\Local\\Programs\\Microsoft VS Code\\code.exe"
            os.startfile(path)
Esempio n. 17
0
def run_genesis():
    cmd = take_in()
    if "open youtube and search for" in cmd:
        songgg = cmd.replace("play", "")
        talk("playing" + songgg)
        print("playing" + songgg)
        pywhatkit.playonyt(songgg)

    if "the time" in cmd:
        tim = datetime.datetime.now()
        timm = tim.strftime("%H;%M")
        print(grt + " the current time is " + timm)
        talk(grt + "the current time is" + timm)

    if "who is" in cmd:
        print(cmd)
        person = cmd.replace("who is", "")
        info = wikipedia.summary(person, 2)
        talk(grt + info)

    if "search for" in cmd:
        src = cmd.replace("search for", "")
        talk("here are the top results" + grt)
        pywhatkit.search(src)

    if "today's date" in cmd:
        date = datetime.datetime.now()
        datee = date.strftime("%Y;%M;D")
        talk("today's date is " + datee)

    if "shut down" in cmd:
        print("shutting down")
        talk("shutting down in 50 seconds")
        pywhatkit.shutdown(50)

    #if the play command is used after each song played,genesis won't loop unless you stop the player by typing "s"
    #it goes directly to music folder and nowhere else
    if "play" in cmd:

        sun = cmd.lstrip("play ")
        mp = ".mp3"
        song = sun + mp
        print("playing " + sun)
        talk("playing" + sun)
        p = Path("C:/Users/personal/Music/")
        song = Path("C:/Users/personal/Music/" + song)
        if song in list(p.glob("*")):
            mixer.music.load(song)
            mixer.music.play()

            while True:
                query = input(">>>")

                if query == "p":
                    mixer.music.pause()
                elif query == "pl":
                    mixer.music.unpause()
                elif query == "s":
                    mixer.music.stop()
                    break

    if "play everything" in cmd:
        play_all()
Esempio n. 18
0
pywhatkit.sendwhatmsg_with_selenium(
    "Phone_Number", "This is a message", 15,
    00)  #Will send message with most of the processes hidden

pywhatkit.send_file(
    "phone_number", "Path to file", 15,
    00)  #Will send file to number with most of the processes hidden

pywhatkit.sendwhatmsg(
    "phone_number", "This is a message", 15, 00
)  #Will open web.whatsapp.com at 14:59 and message will be sent at exactly 15:00

pywhatkit.info("Python", lines=3,
               speak=None)  #Will give information about the topic

pywhatkit.playonyt(
    "Python")  #Will play the first YouTube video having "Python" in it

pywhatkit.search("Python")  #Will perform a Google search

pywhatkit.showHistory(
)  #Will show information of all the messages sent using this library

pywhatkit.shutdown(time=100)  #Will shutdown the system in 100 seconds

pywhatkit.cancelShutdown()  #Will cancel the scheduled shutdown

pywhatkit.watch_tutorial_in_english / hindi(
)  #Will open a tutorial on how to use this library on YouTube in respective language

pywhatkit.help()  #For more information
Esempio n. 19
0
def startAlexa():
    dir = "C:\\songsAlexa"
    if not os.path.exists(dir):
        os.makedirs(dir, exist_ok=True)
    '''
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Author:::::::: Suvansh
    Contact::::::: [email protected]
    Date:::::::::: 10-12-2020
    python:::::::: 3.6.8
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    '''
    global a
    firsttime = True
    FA.PrSpeak("Say Alexa To Start This App")
    while True:
        query = FA.start().lower()
        while "alexa" not in query:
            if "alexa" in query:
                break
            else:
                query = FA.start().lower()
        FA.typeing("Starting This App...\n")
        if firsttime == True:
            FA.wishMe()
        while True:
            query = FA.takeCommand().lower()
            # !-------------------------------------------------------------------------------------------------
            #? ------------------------------------------Searches--------------------------------------------------------
            # !-------------------------------------------------------------------------------------------------

            if 'full wikipedia' in query:
                try:
                    FA.PrSpeak('Searching Wikipedia...')
                    query = query.replace("full wikipedia", "")
                    results = wikipedia.summary(query, sentences=999999999999)
                    FA.PrSpeak("According To Wikipedia...")
                    print(results)
                    FA.speak(results)
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Desplay The Result Because Of Some Issues"
                    )

            elif 'ful wikipedia' in query:
                try:
                    FA.PrSpeak('Searching Wikipedia...')
                    query = query.replace("ful wikipedia", "")
                    results = wikipedia.summary(query, sentences=999999999999)
                    FA.PrSpeak("According To Wikipedia...")
                    print(results)
                    FA.speak(results)
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Desplay The Result Because Of Some Issues"
                    )

            elif 'wikipedia' in query:
                try:
                    FA.PrSpeak('Searching Wikipedia...')
                    query = query.replace("wikipedia", "")
                    results = wikipedia.summary(query, sentences=2)
                    FA.PrSpeak(results)
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Desplay The Result Because Of Some Issues"
                    )


# todo---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#!------------------------------------------------------------------------------------------------------
#?--------------------------------------------Opens-----------------------------------------------------------------------
#!------------------------------------------------------------------------------------------------------
            elif 'open gmail' in query:
                FA.PrSpeak("Opening Gmail...")
                webbrowser.open("gmail.com")
                FA.PrSpeak("Opened Gmail")

            elif 'open gaana' in query:
                FA.PrSpeak("Opening Ganna")
                webbrowser.open("gaana.com")
                FA.PrSpeak("Opened Gaana")

            elif 'open stack overflow' in query:
                FA.PrSpeak("Opening StackOverFlow...")
                webbrowser.open("stackoverflow.com")
                FA.PrSpeak("Opened StackOverFlow")

            elif 'open google' in query:
                FA.PrSpeak("Opening Google...")
                webbrowser.open("google.com")
                FA.PrSpeak("Opened Google")

            elif 'open youtube' in query:
                FA.PrSpeak("Opening YouTube...")
                webbrowser.open("youtube.com")
                FA.PrSpeak("Opened YouTube")

            elif 'open ms teams' in query or 'open microsoft teams' in query:
                FA.PrSpeak("Opening MicroSoftTeams...")
                webbrowser.open("teams.microsoft.com")
                FA.PrSpeak("Opened MicrosoftTeams")

            elif 'open code' in query or "open vs code" in query or 'open visual studio code' in query:
                try:
                    FA.PrSpeak("Opening Visual Studio Code...")
                    codePath = "C:\\Users\\suvan\\AppData\Local\\Programs\\Microsoft VS Code\\Code.exe"
                    os.startfile(codePath)
                    FA.PrSpeak("Opened Visual Studio Code")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Open Visual Studio Code Because Of Some Issue"
                    )

            elif 'open file explorer' in query or 'open explorer' in query:
                FA.PrSpeak("Opening File Explorer...")
                subprocess.Popen('explorer')
                FA.PrSpeak("Opened File Explorer")

            elif 'open zoom' in query:
                try:
                    FA.PrSpeak("Opening Zoom...")
                    zoom = FA.path.get("zoom")
                    os.startfile(zoom)
                    FA.PrSpeak("Opened Zoom")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Open Zoom Because Of Some Issue"
                    )

            # !-------------------------------------------------------------------------------------------------------------------------
    # ?--------------------------------------------Closes------------------------------------------------------------------------
    # !--------------------------------------------------------------------------------------------------------------------------
            elif 'close file explorer' in query:
                try:
                    FA.PrSpeak("Closing File Explorer...")
                    FA.closeFile("explorer.exe", "Explorer")
                    FA.PrSpeak("Closed File Explorer")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Close File Explorer"
                    )

            elif 'close hitman' in query:
                try:
                    FA.PrSpeak("Closing Hitman...")
                    os.system("TASKKILL /F /IM HMA.exe")
                    FA.PrSpeak("Closed Hitman")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Close Hitman")

            elif 'close code' in query or 'close vs code' in query or 'close visual studio code' in query:
                try:
                    FA.PrSpeak("Closing Visual Studio Code...")
                    os.system('TASKKILL /F /IM Code.exe')
                    FA.PrSpeak("Closed Visual Studio Code")
                except:
                    FA.PrSpeak(
                        f"Sorry My Friend I Was Not Able To Close Visual Studio Code"
                    )

            elif 'close zoom' in query:
                try:
                    FA.PrSpeak("Closing Zoom...")
                    os.system('TASKKILL /F /IM Code.exe')
                    FA.PrSpeak("Closed Zoom")
                except:
                    FA.PrSpeak(f"Sorry My Friend I Was Not Able To Close Zoom")
            # !--------------------------------------------------------------------------------------------------------------------------
    #? ---------------------------------------------Others--------------------------------------------------------------------------
    # !--------------------------------------------------------------------------------------------------------------------------
            elif 'codewithharry' in query:
                FA.PrSpeak("Opening Channel CodeWithHarry...")
                webbrowser.open(
                    "www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww")
                FA.PrSpeak("Opened Channel CodeWithHarry")

            elif 'search in youtube' in query:
                FA.PrSpeak("Searching Youtube...")
                a = query
                a = a.split("youtube")
                kit.playonyt(a[1])
                FA.PrSpeak("Searched Youtube")

            elif 'shut down my pc' in query:
                try:
                    FA.PrSpeak(
                        "Shutting Down Your Pc And Wating For 10 Seconds For Your Cancel Shut Down Command..."
                    )
                    kit.shutdown(10)
                except:
                    FA.PrSpeak(f"Unable To Shut Down Your Pc")

            elif 'cancel shut down' in query:
                try:
                    FA.PrSpeak("Cancelling...")
                    kit.cancelShutdown()
                    FA.PrSpeak("Canceled")
                except:
                    FA.PrSpeak("Unable To Cancel Shutdown")

            elif 'play music' in query:
                try:
                    music_dir = "C:\\songsAlexa"
                    songs = os.listdir(music_dir)
                    if len(songs) > 1:
                        FA.PrSpeak("Playing Random Music...")
                        os.startfile(
                            os.path.join(music_dir,
                                         songs[random.randint(1, len(songs))]))
                        FA.PrSpeak("Played Random Music")
                    else:
                        FA.PrSpeak("Playing Random Music...")
                        os.startfile(os.path.join(music_dir, songs[0]))
                        FA.PrSpeak("Played Random Music")
                    FA.PrSpeak(
                        "If You Want To Add Songs You Can Go To c:\\songsAlexa And Add More Songs In It"
                    )
                except:
                    FA.PrSpeak(
                        f"Sorry I Was Not Able To Play Music Please Add Songs In C:\\songsAlexa"
                    )

            elif 'send email' in query:
                try:
                    FA.speak(
                        "Enter The Email Of The Person Whom You Want To send Email"
                    )
                    send = input(
                        "Enter The Email Of The Person Whom You Want To Send Email: "
                    )
                    FA.speak("Enter Your Content")
                    con = input("Enter Your Content: ")
                    FA.PrSpeak("Sending Email...")
                    FA.sendEmail(send, con)
                    FA.PrSpeak("Email Sent")
                except Exception as e:
                    FA.PrSpeak(
                        f"Sorry My Friend I Am Not Able To Send This Email")

            elif 'the time' in query:
                FA.PrSpeak("Telling The Time...")
                strTime = FA.datetime.datetime.now().strftime("%H:%M:%S")
                FA.PrSpeak(f"The Time Is {strTime}")

            #! ----------------------------------------------------------------------------------------------------------------------------------------------------------
    #?----------------------------------------------Talks--------------------------------------------------------------------------------------------
    # !-----------------------------------------------------------------------------------------------------------------------------------------------------------

            elif 'your name' in query:
                FA.PrSpeak('My Name Is Alexa')

            elif 'your version' in query:
                FA.PrSpeak('I Am 1.0.4 Verson Of Alexa')

            elif 'your pet name' in query:
                FA.PrSpeak('I Don\'t Have Any Pet')

            elif 'your favourite pet' in query:
                FA.PrSpeak('My Favourite Pet Is Cat')

            elif 'oh yes' in query:
                FA.PrSpeak('I Think That You Are So Happy')

            # !---------------------------------------------------------------------------------------------------------------------------------------------------------------
    #?---------------------------------------------ImportWarning----------------------------------------------------------------
    # !---------------------------------------------------------------------------------------------------------------------------------------------------------------
            elif 'alexa sleep' in query:
                FA.Quit()
                firsttime = False
                break

            elif 'alexa close yourself' in query:
                FA.PrSpeak("Closing...")
                FA.PrSpeak("Closed")
                a.close()
                exit()

            else:
                pass
Esempio n. 20
0
                print()

            if option == 5:
                print('Enter the file path:')
                path = input("")
                try:
                    print("Opening...")
                    os.startfile(path)
                except FileNotFoundError:
                    print("Can't find the file according to the given path")
                    print()

            if option == 6:
                print("Ok... Set the countdown timer(secs):")
                countdown = int(input())
                kit.shutdown(countdown)
                print('Your system will shut down in', countdown, 'seconds')
                print()
                print(
                    "Do you want to cancel scheduled shutdown?\n1. Yes\n2. No")
                cancel = int(input('Enter numeric input: '))
                if cancel == 1:
                    kit.cancelShutdown()
                    print("Scheduled ShutDown cancelled...")
                    print()
                else:
                    print()
                    continue

            if option == 7:
                print(
Esempio n. 21
0
                to = takecommand()
                talk('what would be the message you want to send')
                content = takecommand()
                talk('at what hours do you want me to send')
                whenH = takecommand()
                talk('at what minutes do you want me to send')
                whenM = takecommand()
                sendwhatsapp(to, content, whenH, whenM)
                talk('message sent sir')
            except Exception as e:
                print(e)
                talk('I am sorry sir...., I am not able to sent the message')

        elif 'shut down my' in command:
            talk('okay sir as you commanded')
            pywhatkit.shutdown(90)
            talk(
                'the computer will be shutting down in less than t minus 90 seconds'
            )

        elif 'cancel shutdown' in command:
            talk('as you commanded to terminate shutdown')
            pywhatkit.cancelShutdown()
            talk('I have terminated the shutdown for you sir')

        elif 'Thanks you' in command:
            talk('not a problem sir ')
            talk('its my responsibility sir')

        # elif 'lets talk' in command:
        #     talk('I have somethings to catch up')
Esempio n. 22
0
            rcvr = names[name]
            #print(names[name])
            talk("What will be the subject sir!")
            sub = get_info()
            #print(sub)
            talk("Tell me the body of the E-mail sir!")
            body = get_info()
            #print(body)
            send_mail(rcvr, sub, body)
            print("Email sent successfully!!!")

        elif 'spell the word' in command:
            word = command.replace("spell the word ", "")
            #print(word)
            ltrs = list(word)
            #print(ltrs)
            for i in ltrs:
                talk(i)
                time.sleep(0.1)

        elif 'exit' in command:
            talk("I'll miss you dear See ya take care.")
            sys.exit(0)

        elif 'get time' in command:
            talk("Today is" + datetime.datetime.now().strftime("%I:%M:%S%p"))

        elif 'shutdown pc' in command:
            talk("Shutting down in 10 secs.")
            pywk.shutdown(time=10)