filmov
tv
Automate Repetitive Tasks With PyAutoGUI | Python Tutorial

Показать описание
Hi guys, my name is Vipul. Today we are talking about how to automate your computer. You might think of automating your computer as this ridiculously hard and complex task.
But it is not. What we can do is basically take the help of the library pyautoGUI. What is this library? Basically, it is a library that uses other libraries or frameworks to do the same exact work that your keyboard and mouse do.
It is much more simple than I am talking, hopefully. So, what it is, is that basically what pyautoGUI does is that it uses frameworks like it uses frameworks like Quartz and AppKit. For Mac, for Windows, it might use cType.
It will use cType library. For Linux, it will use the xlib library. And what this is, is that basically this library is like yeah, do these actions on a much more zero bits level.
So basically, what you are doing here is that you've got this all systems. Now, you can take the help of pyautogui, write in the code, as in click, coordinates, open. You can do anything, like typewrite, something.
So, it is as easy as that. You just have to do that, these few commands. Find, locate, center, that thing.
You can do that and you can automate any task, any process. It's that easy. Just say, click the window button.
You have to know the coordinates. And then search. And then anything can happen, right? So that.
And if you have to pre-program it, you can pre-program it to do anything. As if you were to do it in any other sitting position. It is that easy to automate.
Now, I know, I know, maybe it's not that you want to do that. You can generate this code by LLMs. So, you can generate this code, like, real time.
What you can do is, like, tell the prompt, take the task, give it to the LLM. If you want to be more robust, more precise, maybe you can do this. Is that, you give the task and it will make, it will break the task into much smaller things.
It will make them into more instructable actions. Now, once that has happened, it is much more precise to make the code. Now, what will happen, you make the code, right? You make the code and then after making the code, the better the prompt, the better the process, the better the code.
Now, you've got the code, you copy-paste it, better. Now, if you don't want to copy-paste it, even, that can also work. You just have to tell, you just have to take the code part, right? So, you can either just tell the LLM to not, just only write the code and not the words.
Hopefully, this works. Now, after you do this, you take that to the file, right? First and last line, anything in the codations and name of the language, that can be taken out, right? And then, after that what happens is that, this, this thing that you write, right, it will run. You just have to command it to run and then that's it.
Or whatever action that you told that computer to do, like maybe via voice or maybe some other format, now that's going to be executed. You're actually talking and doing your work. That is as easy as it is.
Now, with this way, I think you get closer to the operator, much lower version of it for free. Hopefully, that should work. I've tried it and it works for me.
Like, I've tried it and I can make the thing work. I just have to do a little tweaks. That's it.
But it is not. What we can do is basically take the help of the library pyautoGUI. What is this library? Basically, it is a library that uses other libraries or frameworks to do the same exact work that your keyboard and mouse do.
It is much more simple than I am talking, hopefully. So, what it is, is that basically what pyautoGUI does is that it uses frameworks like it uses frameworks like Quartz and AppKit. For Mac, for Windows, it might use cType.
It will use cType library. For Linux, it will use the xlib library. And what this is, is that basically this library is like yeah, do these actions on a much more zero bits level.
So basically, what you are doing here is that you've got this all systems. Now, you can take the help of pyautogui, write in the code, as in click, coordinates, open. You can do anything, like typewrite, something.
So, it is as easy as that. You just have to do that, these few commands. Find, locate, center, that thing.
You can do that and you can automate any task, any process. It's that easy. Just say, click the window button.
You have to know the coordinates. And then search. And then anything can happen, right? So that.
And if you have to pre-program it, you can pre-program it to do anything. As if you were to do it in any other sitting position. It is that easy to automate.
Now, I know, I know, maybe it's not that you want to do that. You can generate this code by LLMs. So, you can generate this code, like, real time.
What you can do is, like, tell the prompt, take the task, give it to the LLM. If you want to be more robust, more precise, maybe you can do this. Is that, you give the task and it will make, it will break the task into much smaller things.
It will make them into more instructable actions. Now, once that has happened, it is much more precise to make the code. Now, what will happen, you make the code, right? You make the code and then after making the code, the better the prompt, the better the process, the better the code.
Now, you've got the code, you copy-paste it, better. Now, if you don't want to copy-paste it, even, that can also work. You just have to tell, you just have to take the code part, right? So, you can either just tell the LLM to not, just only write the code and not the words.
Hopefully, this works. Now, after you do this, you take that to the file, right? First and last line, anything in the codations and name of the language, that can be taken out, right? And then, after that what happens is that, this, this thing that you write, right, it will run. You just have to command it to run and then that's it.
Or whatever action that you told that computer to do, like maybe via voice or maybe some other format, now that's going to be executed. You're actually talking and doing your work. That is as easy as it is.
Now, with this way, I think you get closer to the operator, much lower version of it for free. Hopefully, that should work. I've tried it and it works for me.
Like, I've tried it and I can make the thing work. I just have to do a little tweaks. That's it.