You are on page 1of 8

Group No.

5: AI Desktop Assistant

Group Members:
BSCS-FA18-028 ABDULLAH
BSCS-FA18-011 Hafiz Hamza Arslan
BSCS-FA18-044 Muhammad Huzaifa Khan
Task 4: To open the VS Code Program
Steps to get the code path of the application:

Step 1: Open the file location.

Step 2: Right-click on the application and click on properties.

Step 3: Copy the target from the target section

elif
elif'open
'openvc'
vc'ininquery:
query:
codePath = "C:\Users\Window
codePath = "C:\Users\Window
X\AppData\Local\Programs\Microsoft
X\AppData\Local\Programs\MicrosoftVS VSCode\Code.exe"
Code\Code.exe"
os.startfile(codePath)
os.startfile(codePath)
Task 5: To play Audio
To play Audio, I need to import a module called os. Import this module directly
with an import statement.

elif
elif'play
'playaudio'
audio'ininquery:
query:
audio_dir = 'D:\6^th\audio.m4a'
audio_dir = 'D:\6^th\audio.m4a'
sounds
sounds==os.listdir(audio_dir)
os.listdir(audio_dir)
print(sounds)
print(sounds)
os.startfile(os.path.join(audio_dir,
os.startfile(os.path.join(audio_dir,sounds[0]))
sounds[0]))
Problem There are basically six types of permissions in
Windows: Full Control, Modify, Read & Execute, List Folder
Contents, Read, and Write.

elif 'VLC' in query:


vPath = "D:\\vlc\\vlc.exe - Shortcut"
os.startfile(vPath)
Task 6: To know the current time

elif 'the time' in query:


elif 'the time' in query:
strTime
strTime==datetime.datetime.now().strftime("%H:%M:%S")
datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir,
speak(f"Sir,the
thetime
timeisis{strTime}")
{strTime}")
Task 7: To send Email
To send an email, we need to import a module called smtplib.

What is smtplib?

Simple Mail Transfer Protocol (SMTP) is a protocol that allows us to send emails and to
route emails between mail servers. An instance method called sendmail is present in the
SMTP module. This instance method allows us to send an email.
It takes 3 parameters:

The sender: Email address of the sender.


The receiver: T Email of the receiver.
The message: A string message which needs to be sent to one or more than one recipient.
Send email function :

We will create a sendEmail() function, which will help us send emails to


We will create a sendEmail() function, which will help us send emails to
one or more than one recipient.
one or more than one recipient.
def sendEmail(to, content):
def sendEmail(to, content):
server = smtplib.SMTP('smtp.gmail.com', 587)
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.ehlo()
server.starttls()
server.starttls()
server.login('youremail@gmail.com', 'your-password')
server.login('youremail@gmail.com', 'your-password')
server.sendmail('youremail@gmail.com', to, content)
server.sendmail('youremail@gmail.com', to, content)
server.close()
server.close()
Calling sendEmail() function inside the main() function:

elif 'email' in query:


elif 'email' in query:
try:
try:
speak("What should I say?")
speak("What should I say?")
content = takeCommand()
content = takeCommand()
to = "yourEmail@gmail.com"
to = "yourEmail@gmail.com"
sendEmail(to, content)
sendEmail(to, content)
speak("Email has been sent!")
speak("Email has been sent!")
except Exception as e:
except Exception as e:
print(e)
print(e)
speak("Sorry my friend. I am not able to send this email")
speak("Sorry my friend. I am not able to send this email")

You might also like