Python Automation Series #11: How to automate your mouse and keyboard in Python ?
In this tutorial, you will learn how to automate your mouse and keyboard to save your time using a module called PYAUTOGUI.
PYAUTOGUI lets your Python scripts control the mouse and keyboard to automate interactions with other applications, like moving the mouse , clicking , scrolling or typing in the windows of other application to fill out forms and so on
Official documentation link for pyautogui module:
pyautogui.readthedocs.io
Github link for the code : github.com/BekBrace/keyboard-...
DEV profile : dev.to/bekbrace
Github profile: github.com/BekBrace
Пікірлер: 163
I wish i had watched this video before. My tendinitis and the 800 documents i have (now had :D) to check manually until Monday for work thank you a hell of a lot, sir. Awesome content.
@BekBrace
Жыл бұрын
Much appreciated my friend
Thank you, been looking for this for a while. You are a real life saver.
@BekBrace
3 жыл бұрын
I’m glad my friend 🙂
Wow! Great video.
Thanks man , very useful tutorial and a good intro to automation
@BekBrace
Ай бұрын
Cheers
Bro..y ou got a calming voice and a really easy to understand method of teaching, REP+ and hope you find success and it was a really fun experiance learning this from your video.
@BekBrace
11 ай бұрын
Thank you very much my friend 🙏😊
Wow wow... Very very informative and interesting tutorial. 👌👌
@BekBrace
2 жыл бұрын
Thank you my friend
dude’s voice is great
@BekBrace
2 жыл бұрын
Thanks so much 🙂
@donthackme2
Ай бұрын
it's 2:30 am and the video made me even sleepier
@BekBrace
Ай бұрын
That's not a very nice thing to say
@donthackme2
Ай бұрын
@@BekBrace why? I'm not English so can you explain please? I wanted to say that I was tired because it was 2 am but I wanted to watch the video(which I enjoyed) and you voice is calm and charming and it made me even sleepier
@BekBrace
Ай бұрын
Oh, I misunderstood. Usually when you say this, that means that the person talking is boring 😜 But thank you very much for the sweet compliment ❤️🙏
Thank you so much man, I modified my typing thing a bit so I had a delay before it did it and so it did it like 10 times so now I can spam my friends on discord. Thank you so much!!!!!
@BekBrace
2 жыл бұрын
Hehehe 🤭 Great job my friend
Best tutorial
Thank you Bek, it is a very useful video. Clear sound and speed for the training :-bd
@BekBrace
Жыл бұрын
Thank you very much 😊
Is there anyway to make it type the same text but +1 for example cp1, cp2,cp3 ect?
its not giving me the height and width of my screen and im not sure if it imported pyautogui, but i dit watch that part multiple times to check
This is so helpful, thank you!!
Woah!! 'Tis amazin' sir!! Thanks a lot for helpin'!! Love from India!!
@BekBrace
3 жыл бұрын
Thank you LIT Python 🙏
Man this is a pure life saver ! thank you very much , have a nice day :)
@BekBrace
2 жыл бұрын
I am glad, friend :) Have a good day ahead too
@electrocrane
2 жыл бұрын
@@BekBrace man i literally used this pyautogui to cut all my lengthy editing steps in premier pro , so now i can press one button and it'll directly apply one effect to the clip , no need of drag and type over and over again now , PURE LIFESAVER :) trying to learn more for further improvement .
Thanks a lot bro.. your video was very helpful to complete my project work..
@BekBrace
Жыл бұрын
I’m glad brother 🙏 All the best to you
How i can make that the mouse moves and click but only if press a key?
Neat ! Thanks a lot for this video , very helpful
@BekBrace
3 жыл бұрын
Pica _Noris Thank you for watching 😊
I did the drawing thing and it's very cool 😀
Thanks Never been so excited to try code before :D
@BekBrace
11 ай бұрын
You're welcome, brother / sister
Thank you for make this video, it will help me a lot of with my tasks!!
@BekBrace
3 жыл бұрын
I’m very happy you found it useful 👍
@tuckerlangston8528
2 жыл бұрын
You all prolly dont care but does any of you know a trick to get back into an Instagram account? I stupidly forgot my password. I would love any tips you can offer me
Thanks a lot man. really helped me :)
@BekBrace
3 ай бұрын
Gladly ☺️
Amazing Video thank you for such informative content love from india
@BekBrace
3 жыл бұрын
Best regards from Poland
the question is how can i know for example google chrome on desktop axis coordinates what are ???
best vid on the topic thx so much
@BekBrace
3 жыл бұрын
Thank you very much Maor
Best tutorial for this, ever!!!
@BekBrace
Жыл бұрын
Many thanks for your kind words
I need help, I do not want the user to be able to click of type while it is going, please help
Great tutorial !
@BekBrace
3 жыл бұрын
Thank you! Cheers!
can anyone help me how to break a while loop by pressing esc key?
is there a way to loop this?
Great video ❤️. Can we capture the mouse/keyboard event?
how can you run this program?
thanks bro ! i made a script that automatically search things you want in edge , thanks so much
@BekBrace
2 ай бұрын
You're very welcome 🤗
Thanks a lot for this!
@BekBrace
11 ай бұрын
You're very welcome!
how about dual monitor?
This would be so useful I can use my voice controll the computer Thanks im learning python code
@BekBrace
Жыл бұрын
Great ! Keep learning my friend
thanks. this helped me a lot!
@BekBrace
Жыл бұрын
you are very welcome
Helpful video actually
@BekBrace
Жыл бұрын
Cool
thanks, I use this lib to avoid my company tracking myself during work day =) For now have tool that writes me simple code))
@BekBrace
Жыл бұрын
That's awesome !
Hello Bec. Thank you! . I have a question: I try to use complex characters like " \" in a windows path, but pyautogui.typewrite does not work typing this kind of characters. Help me please. Thank you again!
@BekBrace
2 жыл бұрын
Hi There! what are you trying to achieve ?
@sebasy6915
2 жыл бұрын
Hi. I'm working in a boot that open a specific route in CMDER . Sample: pyautogui. Typewrite ("C\archives \programming epository ") but the result is : C archives programming repository. Thank you!
Hey Bek, that was great and informative content, thank you so much for the Video. Do you know, if it is allowed in the terms and services to use pyautogui in the workspace?
@BekBrace
2 жыл бұрын
Thank You so much :) Didn't see anything in the documentations that says otherwise pyautogui.readthedocs.io/en/latest/
i have made this program for 100 iterations that takes 15 minutes in using many applications, so how can i run this automation program in the background? that i wanna save my 15 minutes or do another program or task?
@BekBrace
2 жыл бұрын
That's an excellent question, and I've been looking myself for an automation solution that can run in the background , as long as I know there is no way we can do that, but I'll keep searching for an answer to that question
Thank you so much !! The video was great 👍. I have a question that will the pyautogui.hotkeys() command work if I want to press the windows key and up arrow key together to maximize my window ? Please clear my doubt.
@BekBrace
2 жыл бұрын
Thank you friend 🙂 No, i doubt it as it will be regarded as key interruption
@aradhyakumarchandra8900
2 жыл бұрын
Thank you so much 😁😁
@Handlebrake2
2 жыл бұрын
@@BekBrace so we can't use window commands?
very useful , thanks
@BekBrace
Жыл бұрын
You're very welcome
very clear
@BekBrace
5 ай бұрын
Glad to hear 🍀
I had a dream about pyautogui !
@sknfer
3 жыл бұрын
waaaat ????
Hello Bek! Your video was really useful, I can't thank enough. May I ask, is there a way to make python work in the "background"? What I mean is, how can I do anything else, while the code is running in a specific windows only? Can you advise a tutorial for that? I'd be thankful.
@BekBrace
2 жыл бұрын
Hello my friend, and thank you very much for your comment. Actually, this is very good question, and I have been looking for a solution for this issue; I do some automation macros in VBA for excel, and I have the same issue: I cannot do anything till the macro finishes When I get an answer I will let you know for sure
@EvadingTaxes
2 жыл бұрын
yes you can do that by renaming the file to .pyw
@dualnubs4663
Жыл бұрын
@@EvadingTaxes how bro can you explain or there is a specific vid for that?
Hi Bro. Thank you a lot.
@BekBrace
22 күн бұрын
You are welcome
You're voice is so satisfying
Really very helpful sir
@BekBrace
2 жыл бұрын
Thank you 😊
Thanks for the video. I have tried to use this module. But when scheduling three consecutive clicks outside of Visual Studio Code, the script only do one click. Why will it be?
@BekBrace
3 жыл бұрын
Hello Jose ! Thank you for your comment. I am not sure that I fully understand, what do you mean by " outside of Visual Studio Code " ?
@joseantonioperedarios2811
3 жыл бұрын
@@BekBrace Thanks for answering. I want my script to click on a window of an accounting program, then navigate its menus. I wrote the coordinates of each menu. But when I run the script, it only gives 1 click and not the others that I programmed. Does it have something to do with pillow?
@BekBrace
3 жыл бұрын
@@joseantonioperedarios2811 ohhh I see what you mean. pillow is an images library so I don’t know how it could help in this particular situation, but honestly I never encountered this issue; I’ll try to find a solution and get back to you, meanwhile, you can search the web for an answer
@joseantonioperedarios2811
3 жыл бұрын
@@BekBrace Thanks a lot. I will continue my search.
I know this tutorial is very old but I still have a Question: Is it also possible to hold right click with pyautogui?
@BekBrace
Жыл бұрын
no problem :) as far as I know pyautogui does not have a built-in function for holding down the right-click. However, you can achieve this behavior by combining pyautogui.mouseDown() and pyautogui.mouseUp() functions with the appropriate mouse button parameter.
Thanks man . one question what Function to type a variable
@BekBrace
Жыл бұрын
Come again ?
hi is there anyway we could record down our moves and replay it?
@BekBrace
Жыл бұрын
You mean like a macro recorder ?
@chaimingkai7235
Жыл бұрын
@@BekBrace yep
thank you very much for this video! i just want to doublecheck: once you've created your mouse input function, you could then just inplement this in a while loop, right? to just keep it going for however long? let's say i have 500 papers to click through, i can just let it run? sorry if you covered this in the video. thank you again!
@BekBrace
Жыл бұрын
Yes exactly 😊 You can do precisely that
@chairliftt
Жыл бұрын
@@BekBrace Wow, thank you so much for the quick reply! Cheers!
can pls share mouse move and click , using win32
@BekBrace
Жыл бұрын
sure
I want to move mouse with a xbox controller so this should be helpful thanks
What extension packs do you use?
@BekBrace
2 жыл бұрын
For Python: Visual Studio Intellicode Python Prettier MagicPython
@alexj7693
2 жыл бұрын
@@BekBrace thank you!
I don't see the code by which you moved to Paint. How did you get there?
@BekBrace
2 жыл бұрын
Line 18 through 22
@jesuisravi
2 жыл бұрын
@@BekBrace good. Thanks
Thanks a lot
@BekBrace
2 жыл бұрын
Glad you liked it
pls give python program to change mouse sensitivity
@BekBrace
10 ай бұрын
Ok 👌
Hi, how to know where is our mouse coordinates?
@BekBrace
2 жыл бұрын
Using : pyautogui.position()
import pyautogui ModuleNotFoundError: No module named 'pyautogui' Where is that module?
@BekBrace
2 жыл бұрын
You've got to install first : pip install pyautogui Then you can import it.
perfect vieo
@BekBrace
3 жыл бұрын
Thank you very much 🙏
In my python there is not module named pyautogui
@BekBrace
2 жыл бұрын
You must install it as shown in the tutorial 🙂
How we can install pyautogui module ??
@BekBrace
2 жыл бұрын
Have you watched the video ?
@yassinewaterlaw6597
2 жыл бұрын
@@BekBrace i've fixed the probleme thank you
can we do all this using c language
@BekBrace
2 жыл бұрын
Unlikely, but maybe I'm not sure
canÄt import pyautogui it gets error
@BekBrace
Жыл бұрын
What's the error ?
@schiribeats
Жыл бұрын
@@BekBrace Traceback (most recent call last): File "", line 1, in import pyautogui ModuleNotFoundError: No module named 'pyautogui'
Bro can you please tell me what is your color scheme called it looks so cool.🙏🙏
@BekBrace
2 жыл бұрын
You mean Vscode theme ?
@Abstract_Code
2 жыл бұрын
@@BekBrace yes please
How to typewrite with a delay?????????
@BekBrace
Жыл бұрын
What's that now ?
The voice though !!
@BekBrace
Жыл бұрын
Thanks Ali
what app is that
@BekBrace
2 жыл бұрын
What do you mean
@operator415baza
2 жыл бұрын
Bracket
I use this to make hack client
In none of your videos do you explain to a noob how to get that interface you have. I installed python and run it and it just looks like normal windows command prompt & keeps saying "pip' did you mean 'zip' when I try to install autogui? Plus nowhere can i find the simple looking GUI you have in this vid....how do I get that ? Seriously, there should be a non convoluted way to install this....its easier to just use c++ at this point.....
@BekBrace
Жыл бұрын
In this vid ? you mean "in this video" ! I have no idea what you're talking about when you say "the interface you have". what's the issue with pip ? pip is a package manager through which you can install modules/packages/dependencies that you may use in your app. Again with the "simple GUI you have" - what do you mean ?! Go ahead then work with C++, or try to explain your point of view in a clearer way
Thank you jesus not an indian accent 😭 tears of joy
@BekBrace
2 жыл бұрын
Hehe, that would be offensive to our indian friends but thanks for your comment ,😊
I want to move mouse with a xbox controller so, so I don't have to get Elon Musk's Neurolink chip drilled into my skull, this should be helpful thanks
Win 32 is alot faster then puautogui
@BekBrace
Жыл бұрын
Ok
@lloydchristmas_iii4310
Жыл бұрын
@@BekBrace either way it works...
Trying to do shit in power automate makes me want to eat glass. It kept deleting my flows or crashing and not saving flows. SIMPLE SHIT WHY ARE YOU SO BAD MICROSOFT
@BekBrace
Жыл бұрын
What about Linux ?