PyautoGUI: Three Great Uses

Тәжірибелік нұсқаулар және стиль

In this video I demonstrate the basics of how to use pyautogui in python to control the mouse and keyboard, as well as to take screenshots and locate parts of those images within the visible screen.
If you have a comment, please leave it below or send me an email:
brandon@baldguydiy.com
Please subscribe if you like DIY content in many different areas including electronics, 3D printing, crafting, building, and many more!

Пікірлер: 85

  • @lmamakos
    @lmamakos2 жыл бұрын

    I've been using python for years; I had no idea this library existed! Wow, thanks!

  • @BaldGuyDIY

    @BaldGuyDIY

    2 жыл бұрын

    Thanks for watching! Always new things to learn, especially with Python:)

  • @jesavius
    @jesavius Жыл бұрын

    This dude is spreading the Gosple of this amazing library!!! Was introduced to the library years ago by probably the greatest teacher of Python in the history of time and universe: Al Sweigert. In his book "Automate the Boring Stuff with Python", it's in the freaking title, he goes deep and give so many ideas and use cases. I've automated so many things with this library that it's criminal! I mean let's just say going remote is the greatest blessing after knowing this library. PyAutoGUI has taken calls/messages with Twilio Python SDK, edited created Excel/Google sheets with XLWings, edited PDF files with Reportlab, etc... Don't tell my former or current bosses...

  • @blackcitadel37
    @blackcitadel37 Жыл бұрын

    I discovered this library like a day ago. It's wonderful. Now i have a script for document visualization/analysis with pause/resume and stop features that i can use to check hundreds of documents from clients in my work. Just sitting down, sipping some coffee and looking at screen while the pages flip automatically. No more tendinitis-inducing keyboard mashing. Btw +1 sub here. This was my 1st video here and i love your content already

  • @OnixEdge
    @OnixEdge2 жыл бұрын

    wonderful overview of the pyautogui library. Thank you.

  • @pradumnkumar
    @pradumnkumar Жыл бұрын

    This is an excellent video. I am definitely using this library to automate my mundane tasks.

  • @abdlahelmkhenter5239
    @abdlahelmkhenter52392 жыл бұрын

    what amazing video from a bright prof ... respect

  • @gutenudel611
    @gutenudel6112 жыл бұрын

    Amazing Video... The explanation is objectively speaking at the top of its game... Thumbs Up👍

  • @BaldGuyDIY

    @BaldGuyDIY

    2 жыл бұрын

    Thank you for watching!

  • @pleabargain
    @pleabargain Жыл бұрын

    Thank you. Basic but useful!

  • @maualfaro9244
    @maualfaro92443 жыл бұрын

    Great video, thanks 🤙🏼

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching!

  • @dimikong2842
    @dimikong28423 жыл бұрын

    great video thank you !

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching!

  • @viddeshk8020
    @viddeshk80203 жыл бұрын

    Atlast, I got what I needed

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching! Glad it was helpful.

  • @elyay7203
    @elyay72032 жыл бұрын

    This tutorial is great!!! it helped me with a lot of projects like an ai that can play a certain game (i have the footage in my channel)

  • @g.jignacio
    @g.jignacio2 жыл бұрын

    Very nice introduction to this library! I guess i'll have to dig a little bit deeperr, I see a lot of potential in this tool

  • @BaldGuyDIY

    @BaldGuyDIY

    2 жыл бұрын

    Thanks for watching. So many useful libraries in Python!

  • @netneo71
    @netneo713 жыл бұрын

    Cracking little primer video. I write Python code but haven't used PyAutoGUI. Having watched this I will follow through more on this module. I currently use selenium for web interaction, but this is a great way to use python with software. Thanks for making this video

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching and commenting! I use Selenium a lot too, but the occasional thing is hard to do with it that pyautogui does easily.

  • @chinmayrath8494
    @chinmayrath84942 жыл бұрын

    Thanks

  • @raymondsful
    @raymondsful3 жыл бұрын

    Nice, You made life single.

  • @Jarxay

    @Jarxay

    2 жыл бұрын

    What

  • @fustibal
    @fustibal3 жыл бұрын

    Thanks for this vid, I can now super charge my autohotkey bots with pyautogui. More automation vids please!

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching and for the feedback!

  • @higoramorim85
    @higoramorim853 жыл бұрын

    Thanks from Brazil

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching!

  • @kaiquemachareth4690

    @kaiquemachareth4690

    3 жыл бұрын

    Bora dominar!!

  • @saifsheikh1286
    @saifsheikh12862 жыл бұрын

    Hi, I am trying to click to specific text on desktop screen. kindly help me. I'm new with python. Thanks in advance

  • @leodmx10
    @leodmx10 Жыл бұрын

    I'm from Brazil, it's a pleasure to meet your channel. I'm running PyautoGUI and even with other open screens or programs, the screenshot or locateCenterOnScreen, it always takes the MAC home page, the opening screen without icons, just the background screen and the top menu. Do you know why and how to solve it?

  • @osmardomingos7465

    @osmardomingos7465

    Жыл бұрын

    Creio que seja porque eles utilizam alguma restrição de cópia de conteúdo, ou visualização de computador, no código da página.

  • @notknown9307
    @notknown93073 жыл бұрын

    This video will be viral in some time

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching. You never really know what’s going to go viral. That’s part of the fun:)

  • @darkirontime8566
    @darkirontime85662 жыл бұрын

    great video I learned a lot. How to make a website in php or html by adding this python script to it

  • @Charlietuna49
    @Charlietuna493 жыл бұрын

    Nice video. Is there a way to have the code automatically switch to window you want to keypress? Thanks

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Hi, thanks for watching! It depends what you’re controlling. If you are controlling a web browser, there may be a key command you can type to switch tabs. In Windows you can switch between active programs with ALT+Tab.

  • @f.m.16

    @f.m.16

    3 жыл бұрын

    yoiu can switch in the browser between the tabs with control and tab

  • @uniderpx3452
    @uniderpx34523 жыл бұрын

    I made a small (very slow) bot using pyautogui and pydirectinput to play a roblox fnf game last night. Pyautogui is super cool!

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    I’ve had a few commenters days they’ve automated Roblox. I’ve never played, maybe I should check it out. Glad you found it useful, it is a very powerful module for sure!

  • @mathiolia5877
    @mathiolia58772 жыл бұрын

    Hi sir , can we automate multiple screens drag , is it possible , any idea pls

  • @BaldGuyDIY

    @BaldGuyDIY

    2 жыл бұрын

    The coordinate system used in pyautogui works fine for multiple monitors. Depending how you have them configured, multiple monitors are just stitched together at the edges. So for example, if you had two 1280 x 1024 resolution monitors, the first monitor automation happens between 0 and 1280 horizontally, and between 0 and 1024 vertically. The next monitor automation shows up, if it is to the right, between 1281 to 2560 horizontally and between 0 and 1024 vertically.

  • @nathan7850
    @nathan78503 жыл бұрын

    Hello, thanks for the help but I have a question. It is searching my whole screen for that image and it is taking very long. Does anyone know how to make it faster? I thought maybe something where it is only looking between x pixel and y pixel. If someone has an idea let me know!

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Pyautogui has options on their functions to limits the locates to a range of pixels. Works well if the image you’re looking for always appears in the same area of your screen.

  • @nathan7850

    @nathan7850

    3 жыл бұрын

    @@BaldGuyDIY What is the function called?

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    @@nathan7850 you just add a region option to your locate function. This is the example in the documentation for pyautogui. pyautogui.locateOnScreen('someButton.png', region=(0,0, 300, 400))

  • @nathan7850

    @nathan7850

    3 жыл бұрын

    @@BaldGuyDIY ok thanks

  • @snowjohn2585
    @snowjohn25853 жыл бұрын

    what if I change the browser size then the image size in the browser change ,so I cant match the image ,how can I match the different size but the same button image?

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Depending on the browser, there are usually keyboard hot keys that will set the browser to a standard size (100%). As part of your script you write a line that runs that key sequence, the browser will go to that size, and you base all your images off that. Other Python modules also have functions that set the browser size upon launching, such as Selenium. Thanks for watching!

  • @f.m.16

    @f.m.16

    3 жыл бұрын

    i think, hotkeys are: windows and arrows

  • @chinmayrath8494
    @chinmayrath84942 жыл бұрын

    WOW

  • @michaeldarnell571
    @michaeldarnell5713 жыл бұрын

    I starting using this lastnight to keep me from timing out on roblox. Plus i can train for strength or whatever else for hours at a time

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    I’ve never played Roblox, but that sounds like a fun application. Thanks for watching!

  • @nickplj12

    @nickplj12

    3 жыл бұрын

    @@BaldGuyDIY ROBLOX is a 3D online game that allows players to make games using the Lua programming language.

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    @@nickplj12 thanks for watching. I still have t checked it out, but I should!

  • @CAkashKumar
    @CAkashKumar Жыл бұрын

    using pyautogui

  • @ayushshaw3681
    @ayushshaw36813 жыл бұрын

    I tried pyautogui to play a simple game but it's click is too short for the game to recognize.

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching and commenting! You can create your own click function with pyautogui that would have a longer click time. Use mouseDown and mouseUp with some delay between and you should be able to make something suitable.

  • @richielavey1565

    @richielavey1565

    2 жыл бұрын

    Also make the delay be a random float, not the same or some anti-cheat softwares will detect that

  • @uniderpx3452
    @uniderpx34523 жыл бұрын

    Also, using pycharm I did not have to give permission to click or download pycore after initially importing pyautogui and PIL/pillow. Might be useful for some people.

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Were you using a Mac or PC?

  • @uniderpx3452

    @uniderpx3452

    3 жыл бұрын

    @@BaldGuyDIY Windows which might be the difference. I didnt really consider that

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    @@uniderpx3452 yep, I think it was only required on MacOS. Thanks for watching and commenting!

  • @f.m.16
    @f.m.163 жыл бұрын

    i think that pyautogui has an own sleep function, right?

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    It may, but I didn’t see it in the documentation.

  • @uniderpx3452

    @uniderpx3452

    3 жыл бұрын

    Pyautogui.PAUSE = secsofdelay could be considered the sleep funct?

  • @f.m.16

    @f.m.16

    3 жыл бұрын

    @@uniderpx3452 idk, i just saw a function named pyautogui.sleep(sec) so i thought, it's the same

  • @DavePinnock
    @DavePinnock3 жыл бұрын

    This works great until someone doesn't have the browser app maximized and the search box is no longer in the same location. You need to have a more robust way of giving the search box focus to avoid your script clicking the wrong thing

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    Thanks for watching and for the comment. You are correct that’s it’s not a perfect script. It wasn’t meant to be, just a demo of the mouse, keyboard and screenshot capabilities of pyautogui. Like I said in the video, it’s about building blocks that can be combined with other building blocks. My personal go to for web automation is selenium for everything that can be identified with the browser elements and pyautogui for things that can’t be. I’ve built some fairly complicated and sound automation that way. Pyautogui can be used for anything, not just web browsers. I hope with these kinds of videos it inspires others to give these functions a try in their projects.

  • @DavePinnock

    @DavePinnock

    3 жыл бұрын

    @@BaldGuyDIY Cool, will have to have a look at Selenium. Back in the day I used a tool called autoit to automate software installs on our servers. It had a similar technique and could identify individual elements on web pages and dialogue boxes. I guess my concern was I don't think its that clear in the video that using the position of the mouse cursor is not the most ideal way of activating the search box. Someone new to this might just go ahead and use it not knowing any better. Hope my comments don't come across as too critical, the videos are great and keep them coming, you helped me start out using the ESP32!

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    @@DavePinnock Selenium is what I prefer. The other, probably more popular, web browser module for Python is called Beautiful Soup. I’m happy to have the engagement, critical or otherwise. It’s just nice that people are watching! There are times when I do a finished project, and alternate strategies are very helpful to post and discuss. In these kinds of videos, I just like to show off a couple features and encourage people to check them out. The ability of pyautogui to identify images within a screenshot is super neat and could be used to build a better browser navigator. I recently used it to automate Facebook Live for web streaming, but I didn’t want to show that in the video because of all the personal info that Facebook displays.

  • @DavePinnock

    @DavePinnock

    3 жыл бұрын

    @@BaldGuyDIY Yeah, the ability to recognise images within a screenshot is very cool. Shame you have to take a screenshot first in order for it to recognise it. Would be even cooler to just find that image on the screen itself. I really want to learn more Python but its finding the time for all these projects :) I've just recently finished converting my Raspberry PI. It now runs off an SSD with Ubuntu installed. I was hoping to do more Python scripting on there but so far have only done some bash scripts as they were easier in the end to set up Docker, along and add the containers I needed

  • @BaldGuyDIY

    @BaldGuyDIY

    3 жыл бұрын

    @@DavePinnock you don’t have to take a screenshot first, except to identify the part you want to click on. After that you just use the locate functions. It can be a little slow if you search the whole screen, but if you narrow it down to a portion of the screen it speeds up considerably.

  • @surendratamang8848
    @surendratamang88483 жыл бұрын

    Bnn

  • @gingah609
    @gingah6092 жыл бұрын

    I made a bot to comment random bible verses on random tiktoks!

  • @Robobrine8358
    @Robobrine8358Ай бұрын

    IT IS PYAUTO-G-U-I NOT PYAUTOGOOEY!!!!!!!!!

  • @muc4656
    @muc46562 жыл бұрын

    Pyautogooey

  • @CAkashKumar
    @CAkashKumar Жыл бұрын

    using pyautogui

  • @CAkashKumar
    @CAkashKumar Жыл бұрын

    using pyautogui

  • @CAkashKumar
    @CAkashKumar Жыл бұрын

    using pyautogui

  • @CAkashKumar
    @CAkashKumar Жыл бұрын

    using pyautogui

Келесі