Okay.
Right here in the define.
In the define the function of report.
You see we are printing the log.
Now instead of printing these log right here.
Now you can create a new function.
And then for example sending an email to a specific email.
And then you can call it right here.
So it will send this thing instead of printing your email okay.
So it is how it is working.
And as you see now the code is work.
It looks like it is very ugly.
It is better to use object oriented programming language when you are writing your code and it's uh,
while it is getting more complex.
So here we are going to use classes to make this looks more beautiful.
You may ask, what is a class?
Okay, a class is a blueprint.
While we are using, we put a lot of methods inside the classes, and then we can call it in other files
in this file.
And that is more beautiful and that is easy to use.
Okay, so here we are going to create a new class.
So while creating class just like function we first use the class keyword and then give a name.
So here it's going to be capital key logger okay a logger with capital key.
Now I'm going to highlight everything here and then hit one tab okay.
Now it looks better.
And as you see here we have two two function I think okay one function that is here.
And the other function which is this one which is report function.
Now that I have the class here, I need to use self with each function here as argument.
The first argument is going to be self keyword and also Here.
And also while we are calling in this any function in this part.
Okay.
Any function that you're calling, you need to add the self at the beginning of the name of that.
So you see we have report here.
Now you need to use self dot report.
Okay.
Self dot report.
And also as you see we have another function that is here.
Here again we need to use self dot process key press.
Okay.
And that is good.
Okay.
Right now it is giving me an error.
That is because it is not inside this function.
So as you see right now we have this part that is starting our program.
So it is better to put them into a function.
Okay.
Inside a function.
Here I'm going to going to define a new method or function.
I'm going to name it start function.
So again here I need to give self.
And I'm going to select this.
Hit the tab.
Now it looks a bit okay.
And also here you see we are calling this one.
So we need to use self dot report said report self.
Report self.
This one okay.
Uh no problem.
Okay.
Now that everything looks good.
Uh huh.
Self is not defined by list.
Okay.
That is because of this.
So okay, now the error is gone.
Now you see we have this one.
Okay.
That is, uh, completed.
Now, if I execute, if I run this program, it will do nothing because we never called these, uh,
functions.
And also, we never created an object for this key logger.
Okay, now, if I save this and then go back here, control C, this.
Lets us clear.
See?
We have nothing immediately.
It's, uh, closing that.
So, uh, again here, inside this folder, I'm going to create a new file.
I'm going to name it n logger dot p y.
Okay.
so we have it here.
Okay.
Now I'm going to import the module.
Okay.
It was Ilogger.
Import Ilogger.
And let's create an object.
This is going to be my key logger.
That's equal to we had a class.
The class name was key logger.
Okay.
Not really.
That key logger.
Dot capital key logger.
Okay, let me show you that right here.
Okay.
We have this class with Capital key.
Every time you're importing a you're creating a class.
You need to use capital letter okay.
In the beginning you need to use capital letter.
For example here we have let's see if we have any.
Um, okay.
Here.
You see, we have the timer.
So this timer, the T is capital.
That means this timer is a class.
Okay.
So here the same.
We are importing the key logger.
We're using the key logger.
Dot key logger.
Okay.
So this key logger is a class right now.
And this is its object okay.
We created the object for the key logger.
Now now we have a function called start okay.
So let's use that.
Okay.
My key logger dot start which is a function that is located here okay.
Now whenever you call this function so it will start executing all the program okay.
Now let me save it.
And I'm going to go back here I'm going to use Python.
It was in logarithm pi while I'm executing this.
It is giving me an error and saying that log is not defined in which line.
Line four.
Line 25.
In.
Start.
Line 25 in start.
Okay.
And start.
Function.
Line 24.
Okay.
We don't have it here.
End log.
Okay.
There is one problem, and that is here.
Okay.
We put the log global variable inside the class.
This needs to be out of the class.
Okay.
So for that because of that it gives me a name error.
Like this log is not defined in this location.
And also all other places.
So now if I execute, if I add this okay, from here and put it out of the class.
And let me something like this and I save this, let's come back here.
Now if I type here, for example.
Hello world.
Now you see that it is giving me what I want.
Okay, after each six second, this will give me the report.
Okay.
So it is how you use object oriented programming with Python and there is no big changes.
Okay.
It's the same thing while we were using that before.
Okay.
So since it's so simple, let's go and do something like this part or something.