Hello,
I am trying to get my program to have a reminders function where I can ask it to remind me to do stuff & after a certain amount of time it will remind me about the thing I told it to remind me about.
The only problem I have is that while it's waiting to remind me about the reminder, I would like to still use my program.
Right now, I can set a reminder but it will lock me out of the program until the reminder pops up.
How do I fix it so once the reminder is set I can still use my program & after the specified amount of time, the reminder will just print to the terminal?
Thanks in advance.
Snippet:
Full code:
I am trying to get my program to have a reminders function where I can ask it to remind me to do stuff & after a certain amount of time it will remind me about the thing I told it to remind me about.
The only problem I have is that while it's waiting to remind me about the reminder, I would like to still use my program.
Right now, I can set a reminder but it will lock me out of the program until the reminder pops up.
How do I fix it so once the reminder is set I can still use my program & after the specified amount of time, the reminder will just print to the terminal?
Thanks in advance.
Snippet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#------------------------------------------------------------------------------------- # Set Reminders #------------------------------------------------------------------------------------- if ( 'remind me' in command): command = command.replace( "remind me" , "") autoTypeAnimation( "Ok, I will remind you" + command) import threading t = threading.Thread(target = waiting(command)) t.start() def waiting(command): print ( "Reminder Set" ) # Wait 5s then bring up reminder time.sleep( 5 ) autoTypeAnimation( "FYI: I was told to remind you" + command) |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
#------------------------------------------------------------------------------------- # Imports #------------------------------------------------------------------------------------- import json import random import datetime import operator import os import subprocess import time import sys import webbrowser import requests from bs4 import BeautifulSoup import wikipedia import wolframalpha import pywhatkit from BX_Intents import (greetings, farewell, thanks, noAnswer) from BX_External_Functions import (autoTypeAnimation, StartupText, ShutdownText, UserInput, listen, speak) #------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------- # Commander Name (You) and A.I Name #------------------------------------------------------------------------------------- Commander = "Commander" AI_Name = 'Baxter' #------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------- # WishMe Function #------------------------------------------------------------------------------------- def wishMe(): hour = int (datetime.datetime.now().hour) if hour> = 0 and hour< 12 : speak( "Good Morning" + Commander) elif hour> = 12 and hour< 18 : speak( "Good Afternoon" + Commander) else : speak( "Good Evening" + Commander) #------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------- # Main #------------------------------------------------------------------------------------- def BAXTER(): command = UserInput() #Take user input from terminal command = str (command).lower() #------------------------------------------------------------------------------------- # General Conversation (From Intents.py) #------------------------------------------------------------------------------------- #Greetings patterns, responses = greetings() if (command in patterns): results = (random.choice(responses)) autoTypeAnimation(results) #Print results to terminal speak(results) #Farewell patterns, responses = farewell() if (command in patterns): results = (random.choice(responses)) autoTypeAnimation(results) speak(results) #Thanks patterns, responses = thanks() if (command in patterns): results = (random.choice(responses)) autoTypeAnimation(results) speak(results) #No Response patterns, responses = noAnswer() if (command in patterns): results = (random.choice(responses)) autoTypeAnimation(results) speak(results) #------------------------------------------------------------------------------------- #Search Wikipedia (General Info) #------------------------------------------------------------------------------------- if ( 'weather' not in command): if ( 'who is' in command) or ( 'what is the' in command) or ( 'what is a' in command) or ( "what is" in command): if ( 'time' not in command): if ( 'news' not in command): speak( 'Searching...' ) command = command.replace( "who is" ,"") command = command.replace( "what is the" ,"") command = command.replace( "what is a" ,"") command = command.replace( "what is" ,"") results = wikipedia.summary(command, sentences = 2 ) autoTypeAnimation(results) speak(results) #------------------------------------------------------------------------------------- #Search Wolfram Alpha (Math/Conversions, Definitions) #------------------------------------------------------------------------------------- if ( 'news' not in command): if ( 'weather' in command) or ( 'calculate' in command) or ( "what's" in command) or ('define' in command) or ( "what" in command): speak( 'Searching...' ) command = command.replace( "calculate" ,"") command = command.replace( "what's" ,"") command = command.replace( "define" ,"") # Wolframalpha App Id appId = 'JH9XHR-W9J76L7H5A' # Wolfram Instance client = wolframalpha.Client(appId) res = client.query(''.join(command)) results = next (res.results).text autoTypeAnimation(results) speak(results) #------------------------------------------------------------------------------------- #Open Stuff on the Internet #------------------------------------------------------------------------------------- #Open Youtube Videos (Ex: 'Play __ on youtube') if ( 'youtube' in command): autoTypeAnimation( "Launching Youtube..." ) speak( 'Launching Youtube' ) command = command.replace( "youtube" ,"") pywhatkit.playonyt(command) #Open Google Maps and Find The Location of A You Want if ( 'where is' in command): command = command.replace( "where is" ,"") autoTypeAnimation( "Locating" + command + "..." ) speak( 'Locating' + command) #Search Stuff on Google if ( 'search' in command): command = command.replace( "search" , "") autoTypeAnimation( "Searching" + command + " on Google" ) speak( 'Searching' + command) pywhatkit.search(command) #Close Firefox if ( 'close firefox' in command): autoTypeAnimation( "Terminating Firefox..." ) speak( 'Closing Firefox' ) command = command.replace( "close firefox" , "") browser = "firefox.exe" os.system( "taskkill /f /im " + browser) #------------------------------------------------------------------------------------- #Open Stuff on the Computer #------------------------------------------------------------------------------------- #Open Windows Media Player and Auto Play the Playlist Called Music if ( 'play music' in command) or ( 'media player' in command) or ( 'drop the needle' in command): autoTypeAnimation( "Launching music..." ) speak( "Launching Music" ) command = command.replace( "play music" , "") command = command.replace( "media player" , "") command = command.replace( "drop the needle" , "") subprocess.Popen( "C:\Program Files (x86)\Windows Media Player\wmplayer.exe /Playlist Music" ) #Close Windows Media Player if ( 'stop music' in command): autoTypeAnimation( "Terminating music..." ) speak( 'Closing Music' ) command = command.replace( "stop music" , "") mediaPlayer = "wmplayer.exe" os.system( "taskkill /f /im " + mediaPlayer) #------------------------------------------------------------------------------------- # Set Reminders #------------------------------------------------------------------------------------- if ( 'remind me' in command): command = command.replace( "remind me" , "") autoTypeAnimation( "Ok, I will remind you" + command) import threading t = threading.Thread(target = waiting(command)) t.start() #autoTypeAnimation("FYI: I was told to remind you" + command) #------------------------------------------------------------------------------------- #Stop Program/Script Command #------------------------------------------------------------------------------------- if ( 'stop' in command) or ( 'shutdown' in command) or ( 'quit' in command): speak( "Shutting Down..." ) results = "Terminating program..." autoTypeAnimation(results) ShutdownText() exit() #------------------------------------------------------------------------------------- #------------------------------------------------------------------------------------- def waiting(command): print ( "Reminder Set" ) # Wait 5s then bring up reminder time.sleep( 5 ) autoTypeAnimation( "FYI: I was told to remind you" + command) #------------------------------------------------------------------------------------------ # Run The Program #------------------------------------------------------------------------------------------ StartupText() wishMe() speak( "How may I be of service?" ) while True : BAXTER() #------------------------------------------------------------------------------------------ |