Jarvis
Now we are going to create some functions. In this function J.A.R.V.I.S. will do the following things.
1. Close a software by using file location - e.g. Notepad
2. Find IP address of the system
Ok Lets Start our Code.
close notepad()
# To close Notepad
def close_notepad():
speak("closing notepad")
os.system("taskkill /f /im notepad.exe")
ip_address()
# To find IP address of the system
def ip_address():
ip = requests.get("https://api.ipify.org").text
speak(f"your IP addres is {ip}")
Place the above code in between the Previous code and call the function in the main block of the code
which means,
if __name__ == "__main__":
wish()
query = takecommand().lower()
if "open notepad" in query:
notepad()
elif "open cmd" in query:
cmd()
elif "close notepad" in query:
close_notepad()
elif "ip address" in query:
ip_address()
No comments:
Post a Comment