-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersonal assistant.cpp
236 lines (199 loc) · 9.18 KB
/
personal assistant.cpp
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#include<bits/stdc++.h>
#include<iostream>
#include<windows.h>
#include<stdio.h>
#include<string.h>
#include<cstdlib>
#include<ctime>
using namespace std;
//function to greet the user according to time
void greetings()
{
//current time and date based on our system timezone
time_t now = time(0);
tm *time = localtime(&now);
if(time->tm_hour<12){
cout<< "Good Morning Amisha"<<endl;
string phrase = "Good Morning Amisha";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
else if (time-> tm_hour >= 12 && time->tm_hour <= 16){
cout<< "Good Afternoon Amisha"<<endl;
string phrase = "Good Afternoon Amisha";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
else if (time-> tm_hour > 16 && time->tm_hour < 24){
cout<< "Good Evening Amisha"<<endl;
string phrase = "Good Evening Amisha";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
}
void datetime(){
time_t now = time(0);
char *dt = ctime(&now);
cout<<"The date and time is "<<endl<<dt<<endl;
}
int main(){
system("cls");
cout<< "\t<###################################### PERSONAL ASSISTANT #######################################"<<endl<<endl;
string password;
string command;
do
{
cout<<"******************************************"<<endl;
cout<<"ENTER THE PASSWORD TO CONFIRM YOU ARE AMISHA"<<endl<<endl;
cout<<"******************************************"<<endl<<endl;
string phrase= "ENTER THE PASSWORD TO CONFFIRM YOU ARE AMISHA";
string command = "ESPEAK \"" + phrase + "\"";
const char *charCommand= command.c_str();
system(charCommand);
getline(cin,password);
STARTUPINFO startInfo={0};
PROCESS_INFORMATION processInfo={0};
if(password=="amisha")
{
cout<<"\n<***************************************************************************************>\n\n";
greetings();
do{
cout<<"\n<***************************************************************************************>\n\n";
cout<<endl<<"HOW CAN I HELP YOU AMISHA...."<<endl;
string phrase = "How can i help you Amisha";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
cout<<"Enter your question ===> ";
getline(cin,command);
cout<<endl;
cout<<"Answer to your question is ===> ";
if(command=="hello" || command=="hi")
{
cout<<"Hello Master Amisha....."<<endl;
string phrase = "Hello Amisha";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
else if(command=="what is the time")
{
datetime();
}
else if(command=="who are you" || command=="who is speaking")
{
cout<<"I'm a personal assistant created by Amisha !!!"<<endl;
string phrase = "I'm a personal assistant created by Amisha !!!";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
else if(command=="open notepad")
{
cout<<"opening notepad.."<<endl;
string phrase= "opening notepad";
string command ="espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
CreateProcess(TEXT("C:\\Windows\\notepad.exe"), NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &startInfo, &processInfo);
}
else if(command=="open Microsoft Excel")
{
cout<<"opening Microsoft Excel"<<endl;
string phrase = "opening Microsoft Excel";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
CreateProcess(TEXT("C:\\Program Files\\WindowsApps\\Microsoft.Office.Desktop.Excel_16051.14326.20238.0_x86__8wekyb3d8bbwe\\Office16\\EXCEL.exe"), NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &startInfo, &processInfo);
}
else if(command=="open Microsoft Word")
{
cout<<"opening Microsoft Word"<<endl;
string phrase = "opening Microsoft Word";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
CreateProcess(TEXT("C:\\Program Files\\WindowsApps\\Microsoft.Office.Desktop.Word_16051.14326.20238.0_x86__8wekyb3d8bbwe\\Office16\\WINWORD.exe"), NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &startInfo, &processInfo);
}
else if(command=="open Microsoft Paint")
{
cout<<"opening Microsoft Paint"<<endl;
string phrase = "opening Microsoft Paint";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
CreateProcess(TEXT("C:\\Windows\\System32\\mspaint.exe"), NULL, NULL, NULL, FALSE, NULL, NULL, NULL, &startInfo, &processInfo);
}
else if(command=="open google")
{
cout<<"openining google"<<endl;
string phrase = "opening google";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
system("start https://www.google.com");
}
else if(command=="open youtube")
{
cout<<"openining YouTube"<<endl;
string phrase = "opening youtube";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
system("start https://www.youtube.com");
}
else if(command=="close chrome browser")
{
cout<<"closing chrome browser"<<endl;
string phrase = "closing chrome browser";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
system("TASKKILL /IM chrome.exe /F");
}
else if(command=="open photo")
{
cout<<"opening photo"<<endl;
string phrase = "opening photo";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
ShellExecute(NULL,"open","avengers.png",NULL, NULL, SW_NORMAL);
}
else if(command=="bye" || command=="exit")
{
cout<<"Good Bye Amisha, see you soon!"<<endl;
string phrase = "Good Bye Amisha, see you soon!";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
exit(0);
}
else
{
cout<<"Sorry could not understand your command please try again !!!"<<endl;
string phrase = "Sorry could not understand your command please try again";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
}while(1);
}
else
{
system("cls");
cout<<"\t<################################### PERSONAL ASSISSTANT ########################################"<<endl<<endl;
cout << "**********************" << endl;
cout << "X Incorrect Password X" << endl;
cout << "**********************" << endl << endl;
string phrase = "Incorrect Password, please enter correct password";
string command = "espeak \"" + phrase + "\"";
const char *charCommand = command.c_str();
system(charCommand);
}
}while (1);
return 0;
}