PyAutoGUI - Locate anything on your screen | Simple Pyautogui project

Поділитися
Вставка
  • Опубліковано 4 жов 2024

КОМЕНТАРІ • 255

  • @coding101withsteve8
    @coding101withsteve8  8 місяців тому +6

    Hello All 🙋🏻‍♂️
    If you have any kind of customized tool or app request. You can reach out to me on Instagram or email. I can create tools or apps for you.
    instagram.com/stevegen1907
    OR
    coding101withsteve.freelance@gmail.com
    Thank You

    • @lukkaskkjk
      @lukkaskkjk 2 місяці тому

      Thanks for the tutorial Steve, can you do a tutorial teaching us how to create a bot that detects if the image is appearing on the screen or not?

  • @olisamping5339
    @olisamping5339 Рік тому +60

    IDK why but Indians is the best techno teacher. Your explanation is so clear. Thank you

  • @macavitymacavity126
    @macavitymacavity126 10 місяців тому +6

    Steve, I really went far in a personal project after watching your stuff. You are a really good teacher, you not only give great content and information, you show the mindset of how to take on each task and problem. Thx a lot.

    • @coding101withsteve8
      @coding101withsteve8  10 місяців тому +2

      Thank you so much. I'm glad to know it helped you to go far in your project ❤
      All the best

  • @Tinyjb0
    @Tinyjb0 6 місяців тому +1

    Thanks for the quick and easy to understand tutorial!

  • @d8822d
    @d8822d 2 роки тому +6

    Great channel, Upload more!

    • @coding101withsteve8
      @coding101withsteve8  2 роки тому

      Thank you. That's the plan.

    • @d8822d
      @d8822d 2 роки тому

      @@coding101withsteve8 Yes, if you do it 3 times a week, your channel will have 100k subs in few month mark my words.just keep making content about python only

  • @Enthralpy
    @Enthralpy Рік тому +10

    Loved the video! Feels like I can do a LOT more now than I could before.
    Also, you can combine moveTo() and click() with click(x = (enter X coordinates), y = (enter Y coordinates)). And I ran into an issue where my brower took too long to load the page before it could find the Search bar, so I made a function that makes your program wait before trying to find an image incase your browser loads too slowly:
    import pyautogui as pag
    def find(img):
    while True:
    try:
    x, y = pag.locateCenterOnScreen(img, confidence=0.9)
    print("Found")
    return (x, y)
    except TypeError:
    sleep(1)
    print("Waiting")
    pass
    You would use it like this:
    xy = find("image.png")
    click(xy)

  • @GuilhermeHenriquedeLima-bu9eu
    @GuilhermeHenriquedeLima-bu9eu 3 місяці тому

    Perfect video. You made my day Steve. Thank you.

  • @Michael-hs2wh
    @Michael-hs2wh 9 місяців тому

    That tool is so increadibly helpful

  • @yajnalgibno6536
    @yajnalgibno6536 9 місяців тому +5

    To the folks who encountering this error message
    "PyAutoGUI was unable to import pyscreeze. (This is likely because you're running a version of Python that Pillow (which pyscreeze depends on) doesn't support currently.) Please install this module to enable the function you tried to call."
    Try running this in terminal: pip install --upgrade pillow

  • @ff_0xx266
    @ff_0xx266 8 місяців тому

    Thank you, this helped me so much! I love the demonstration, you explained it perfectly!

  • @picofa
    @picofa 2 роки тому

    Thanks, this was a great start for me, I automated some task using try and except, and a while that cicles every second and search if one of the images show on the screen, if the locateonscreen function doesn't find it, it shows an error and doesn't continue inside the try function. If the images is found there is no error and a code of a macro can be executed.
    I would add to this video that the cheat sheet of the pyautogui library is very useful, can be found on Google.
    The functions pyautogui.position() (print mouse position) and pyautogui.moveTo(x=1857, y=1944, duration = 0.2) (where x and y are positions on screen) can be used to click on something else that is not the center of the image, and is very useful for automation purposes.
    A code example of what I did:
    import pyautogui
    import cv2, numpy
    import time
    pyautogui.position() # find mouse position for developing
    while(True):
    time.sleep(1) # wait 1 second before another cicle
    try:
    x, y= pyautogui.locateCenterOnScreen(r"image_path.png", confidence = 0.9)
    pyautogui.moveTo(x=1873, y=1634, duration = 0.2)
    pyautogui.leftClick()
    time.sleep(1)
    pyautogui.moveTo(x=1857, y=1944, duration = 0.2)
    pyautogui.leftClick()
    time.sleep(1)
    except:
    None
    Also, you need to install "pip install opencv-python", it is required too.
    To exit the cicle I stop it from the terminal, there is also a funcion on pyautogui to exit a program, it is pyautogui.FailSafeException.
    I hope this comment can help someone.

  • @arthursullivan7393
    @arthursullivan7393 3 місяці тому +2

    Image not found problem: multi monitors
    PyAutoGui only supports the primary monitor, test your code on the primary and it will work fine.

  • @arbangsg
    @arbangsg Рік тому

    Thx so much you are the best teacher for me

  • @xilllllix
    @xilllllix 4 місяці тому

    needed this tutorial today, thanks!

  • @gabrielt3578
    @gabrielt3578 Рік тому +2

    Clear code, nice video! Thank you bro

  • @KauaLopes-xz4uf
    @KauaLopes-xz4uf Рік тому

    thanks friend you are a friend, I needed to know how to use the image function thanks, I just found the way you use write but I'm a newbie in automo so I need to learn more.

  • @bagumandal
    @bagumandal Рік тому

    I love your vlogs! They are so entertaining and informative.

  • @palap9506
    @palap9506 Рік тому

    thanks brother, this is very good, it worked for me. i gained so much knowledge. because you i will try progrmaming

  • @jacktapping
    @jacktapping Рік тому +1

    Great video this is going to help a lot on a machine vision project I'm working on

  • @GrantNaylor-b8l
    @GrantNaylor-b8l 5 місяців тому

    A good working example 👍

  • @Machiuka
    @Machiuka 7 місяців тому

    Awesome tutorial. I've learned a lot from it.

  • @a-b-c
    @a-b-c Рік тому +3

    Thanks bro, That was great tutorial, it made me realise the value of AutoHotKey scripts I write for the very purpose, they are very short and intuitive, I mean I can subscribe any channel with those scripts without inputting their logo. There's nothing we could really do, python needs to evolve.

  • @Maliksmm786
    @Maliksmm786 9 місяців тому

    bro please make a complete python course. Because you teching method is very simple and attractive.

  • @pibruks
    @pibruks Рік тому

    love this tutorial man Thank you. Hello from Ecuador

  • @torque6389
    @torque6389 2 місяці тому

    Amazing!

  • @jonathanacuna
    @jonathanacuna 2 роки тому +2

    So incredibly helpful!!!!

  • @adamstewarton
    @adamstewarton Рік тому +8

    Hi , there is an easier way to get the XY cords from your screen.
    You can write a small script in python:
    import pyautogui as pag
    pag.displayMousePosition()
    if you run it, it will display the cords of your mouse at any time

    • @NatureIsAmazing208
      @NatureIsAmazing208 Рік тому

      maybe im stupid but it just gives me like 150 errors

    • @aaquibtayyabi
      @aaquibtayyabi Рік тому

      @@NatureIsAmazing208 150 ? lol dk about that but check if you have installed the pillow package through pip and try debugging again

  • @sumairahashmi7825
    @sumairahashmi7825 2 роки тому

    Thanks bud! great video and instructions.

  • @Simpletips55
    @Simpletips55 Рік тому

    🎉great video you saved my time😊

  • @higiniofuentes2551
    @higiniofuentes2551 Рік тому

    Thank you for this very useful video!

  • @MassimoCLI
    @MassimoCLI Місяць тому

    Hi Steve, this video is even better than previous one regarding pyautogui. Double thumbs up. I'm Italian and I'd like to prepare a video summarizing the beauty of Python, may I link and suggest your videos. Thanks 👍

  • @sudgamer4639
    @sudgamer4639 2 роки тому

    Ima download it thanks for sharing!!

  • @Mashtainment
    @Mashtainment Місяць тому

    amazing!

  • @bananenpflanzer6516
    @bananenpflanzer6516 Рік тому

    Hey this was a really good video i subscribed, thank you so much

  • @eanlakins1754
    @eanlakins1754 2 роки тому +7

    The pyautogui locateonscreen feature gives me the failed to read, file is missing, has improper permissions, or is an unsupported or invalid format. Any suggestions to fix this??

    • @buildsrike791
      @buildsrike791 Рік тому

      Same as me

    • @24-Card
      @24-Card Рік тому

      Is the png saved locally (to the location of the executable)?

  • @nicolassuarez2933
    @nicolassuarez2933 4 місяці тому

    Outstanding! Do we have a newer alternative? Thanks

  • @nenjuvalitamilreview7512
    @nenjuvalitamilreview7512 Рік тому

    very interesting concept ! thanks mate

  • @bubblebath2892
    @bubblebath2892 5 місяців тому

    Brilliant Video bro

  • @michellenijman9878
    @michellenijman9878 Рік тому

    You are the boss bro!!! Thank you a lot!

  • @keremmert1986
    @keremmert1986 2 місяці тому

    Hello Steve, i am appreciate you made very usefull videos, thank you. I have a different problem with automating. I want to able using muose while automate clicking typing etc. on my other screen. Will it be possible with vscode or power automate? I will be so happy if you help me in this problem. Good day sir.

  • @gouranga1876
    @gouranga1876 Рік тому

    It's very helpful

  • @rushikeshpachpute99
    @rushikeshpachpute99 2 роки тому +1

    year. I want to get into making soft on desktop because it offers more features but I have just been preferring the softow of mobile apps

  • @Harishkumar-tt1nd
    @Harishkumar-tt1nd 2 місяці тому

    Hello steve, any solution for searching a text on window and click on it without using images for searching

  • @meraklmuskulpesent8313
    @meraklmuskulpesent8313 2 роки тому +3

    Hi, for some reason, locateOnScreen function always returns None, despite both the code and the image are located in the same folder. Thank you.

  • @malkirupasinghe1931
    @malkirupasinghe1931 Рік тому

    කෝ අයියෙ ඔයාගෙ mtfe වීඩියෝ..ඒව හැමදාම මම බලනව ,දැන් පේන්න නෑනෙ එකක්වත්

  • @mandeepyadav7253
    @mandeepyadav7253 2 роки тому

    NICE VIDEO SIR

  • @AlexanderWeurding
    @AlexanderWeurding Рік тому

    Thanks from NL!

  • @amz_news
    @amz_news Рік тому +1

    if you use this method to subscribe to multiple channels can youtube detect this and cancel the subscriptions?

  • @alexeymatveev9031
    @alexeymatveev9031 Рік тому

    pure gold!

  • @Rainquiller
    @Rainquiller 2 роки тому +4

    question. where did you save the image file? should it be in the python directory or anywhere in pc?

    • @donaldtrunp4597
      @donaldtrunp4597 2 роки тому +1

      You can save it anywhere in the PC and copy its location. But for me I would prefer creating a python directory for your photos so that it would be pretty much easier to find and organized.

    • @dominusdone5023
      @dominusdone5023 Місяць тому

      I had persmission problems so I put it in the same folder as my code

  • @extrememike
    @extrememike 10 місяців тому

    Pretty cool!

  • @malcomivan
    @malcomivan 11 місяців тому +1

    brother can help me how can i do this: i have 3 pic (jpg) number 1,2,3 in my screen i must choose the correct, how i say to python click in number 2 knowing is number 2, the number 2 is in the middle for example. thanks, i have screeenshot saved of numbers, but after?

    • @coding101withsteve8
      @coding101withsteve8  9 місяців тому +1

      Check my other video on Pyautogui. There you'll learn the basic commands. It would be better to use coordinates for clicking particular image among 3 images.

  • @freetorunfree
    @freetorunfree 6 місяців тому

    thank you for your explanation very helpful!
    Just one question that you did not call any browser in the code does pyautogui understands that it has to pull up a browser.

    • @coding101withsteve8
      @coding101withsteve8  6 місяців тому

      No it doesn't. It just looks for the image on the screen, and performs the click or key press operations.
      It's more like a human eye. What is seen on the screen. If there is an app open behind an already opened app. Pyautogui won't see it.

  • @edinetgrunhed6000
    @edinetgrunhed6000 Рік тому

    thanks for this , can you make video but this time to monitor a when use click "EDIT" button or any custom button (using snippet) and print to screen

  • @AyaAya-fh2wx
    @AyaAya-fh2wx Рік тому

    Thank you so much!!!!!

  • @AmDsus2Fmaj7Am
    @AmDsus2Fmaj7Am Рік тому

    This is brilliant

  • @mandeepyadav7253
    @mandeepyadav7253 2 роки тому

    nice video

  • @Ditebogomojapelo
    @Ditebogomojapelo 8 місяців тому

    😀😀woooooow no ways!!!

    • @Ditebogomojapelo
      @Ditebogomojapelo 7 місяців тому

      Hello sir, what file formatter extension can I use for my code to have the same colors are yours? I have Prettier installed but I just learnt that prettier does not support Python.
      My goal is for the colors on my code in VScode to look like yours.

  • @oxydripgen
    @oxydripgen 2 роки тому +6

    great tutorial. I still have a question, when i run the same code as you did in 2:07 it says "OSError: Failed to read image.png because this file is missing, has improper permissions, or is an unsupported or invalid format"... i have saved the file in the same directory as my program as an png file. I also tried with other files. do you maybe know the issue?

    • @coding101withsteve8
      @coding101withsteve8  2 роки тому +1

      Hello. Thank you for your comment.
      It could be possible that the image file was of another format before and you just changed the extension. Eg. If it was image.jpg... You changed it nto image.png. then this error can come.
      Secondly you can try renaming the file.
      Thanks you. Hope that helps 😇

    • @oxydripgen
      @oxydripgen 2 роки тому +2

      @@coding101withsteve8 thank you for the answer aswell, i already fixed my issue, i am new to python and did not have my folder open, so my program couldn't recognize the images in the folder

    • @coding101withsteve8
      @coding101withsteve8  2 роки тому

      @@oxydripgen Glad you solved it on your own. ☺

    • @tuvelout
      @tuvelout Рік тому

      @@oxydripgen having the folder with the file ".png" open or close shouldn't make any difference, only if it was there you obtained the croped image, program was searching for.

    • @pluderr3947
      @pluderr3947 Рік тому

      @@tuvelout Hey man, it doesn't work for me. I have it saved as a PNG file but it still doesn't work. Do you know what the issue would be?

  • @ashrafulalam6881
    @ashrafulalam6881 Рік тому +1

    where i can get the code to run, test and learn

  • @HungryK
    @HungryK Рік тому

    Thank you!

  • @vivianpaul2078
    @vivianpaul2078 2 роки тому

    subscribed ur channel using this method :)

  • @dari0073
    @dari0073 Рік тому

    Hey i am really new to Python and and i a very paranoid person so i dont really like installing anything. So my question is: How do i know if its safe to install any Libary? I want to install one called ..pyautogui.. and dont know how to check if its safe. Thx for any answer and Great Video

    • @coding101withsteve8
      @coding101withsteve8  9 місяців тому

      Hey, I found a very nice article here. You can check it out 😇
      www.codethink.co.uk/articles/2023/pypi-safety/#:~:text=You%20can%20use%20a%20tool%20such%20as%20pip%20audit%20to,Python%20dependencies%20have%20known%20vulnerabilities.

  • @vetrivelr5708
    @vetrivelr5708 2 роки тому +3

    Hey steav, your videos and explanations are really awesome. Please keep going
    I have a following question:
    1) can we avoid any manual intervention by users during the execution of script?
    Because that is the whole idea i required.
    2) when we share this Script file to other users then they should hold the same PNG files in the same location right?
    Because i am really looking for an concrete automation as an alternative of RPA tools. Thats why asking.
    Please, need your suggestion.

    • @coding101withsteve8
      @coding101withsteve8  2 роки тому +1

      Hello
      1. No you cannot avoid manual intervention. You'll have to use it on a seperate machine.
      2. I had tried that but it did not work. The pixels of other machines changes. You can try to change the other machine's display settings. But still I believe you'll have to take new screen shots.
      Thank you.

    • @vetrivelr5708
      @vetrivelr5708 2 роки тому

      @@coding101withsteve8 Thanks steve for detailed explanation.
      But if other users having same screen size resolution of mine will that work, if i share script & images and ask them to Store it on a specific location and run.?
      Example: My screen size is 1980×1080 then other user's also having same size of resolution will that work?

  • @CadaverTheGhoul
    @CadaverTheGhoul Рік тому

    if im using pyautogui and i have 10 different instances running and when they handle errors they need to use pyautogui to handle them but whichever tab is the active one on my screen ie whichever instance launced last ends up getting messed with when it is another one buried behind it that is having an error, how do i switch to the tab of python/selenium code that is having the error?

  • @jpveral
    @jpveral 2 роки тому

    So perfect

  • @AbhisheKumar45
    @AbhisheKumar45 Місяць тому

    How to click 3 buttons at the same time like create a new folder using Ctrl+Shift+N plz explain

  • @animevietsub_ne
    @animevietsub_ne Рік тому

    I want to ask 1 question
    Can I copy, print and delete in PyAutoGUI function?
    (delete the part I just entered)
    Hope you can reply me!

  • @HKRajnish
    @HKRajnish Рік тому

    If I have two same images on screen how to locate the second one? Urgent please

  • @arcticfox3840
    @arcticfox3840 3 місяці тому

    What happens if I two same things in my screen?

  • @lessonsthehardway
    @lessonsthehardway 3 місяці тому

    great video except I tried screenshotting the edit button like you and it kept saying image not found, i did it like 5 times, and one of them worked randomly, there was no difference. And now again, its not reading any of them anymore, how do u fix?

    • @coding101withsteve8
      @coding101withsteve8  26 днів тому

      Try using the confidence attribute. Check my other pyautogui video too 😇

  • @anormalzz
    @anormalzz 2 місяці тому

    thanks

  • @ojoaopedror
    @ojoaopedror Рік тому

    Hey dude! Thanks a lot for your great tutorial. I only have one problem, when pyautogui opens the app I need to automate, the code stops giving commands. Can you help me?

  • @dimaE965
    @dimaE965 Рік тому

    Thank you.

  • @Beeater-i2c
    @Beeater-i2c 2 місяці тому

    I have a simple bot for a website that I use, but it stopped working(site update). It’s a typescript and follows a selenium-based script that uses a very simple algorithm. Do you think you can help me identify the problem? Thank you very much for your time and effort!!!!

    • @coding101withsteve8
      @coding101withsteve8  2 місяці тому

      You can share the selenium code and error you're facing along with the website url on my mail. I'll try and check. 😇

    • @Beeater-i2c
      @Beeater-i2c 2 місяці тому

      @@coding101withsteve8 ok great, what is your email?

    • @Beeater-i2c
      @Beeater-i2c 2 місяці тому

      @@coding101withsteve8 ok where do i send it?

  • @AshuKumar-lo5vt
    @AshuKumar-lo5vt Рік тому

    Please tell me, how can I read live data from running applications?

  • @ayushagrawal9916
    @ayushagrawal9916 9 місяців тому

    pysceeze is not working in latest python versions

  • @persons2480
    @persons2480 2 роки тому

    Hello, I was wondering how I could locate a certain color pixels then have my mouse follow those pixels, all in pyautogui.

  • @miguelvallejos5868
    @miguelvallejos5868 2 роки тому

    Em....when we finished to compose how to get it out ?

  • @comet942
    @comet942 Рік тому

    thank you

  • @washington1266
    @washington1266 8 місяців тому

    muito bom, eu diria

  • @martineschle9149
    @martineschle9149 9 місяців тому

    Danke!

  • @aryangoswami5639
    @aryangoswami5639 Рік тому

    automatic comment done using pyautogui

  • @afnanahmad4266
    @afnanahmad4266 2 роки тому +1

    Bro what if i want to click under an image that has random location on the screen everytime page refreshes.
    i want it to click on all the pixels in certain area under the image

    • @coding101withsteve8
      @coding101withsteve8  2 роки тому +1

      You can find the location of the image and then to click below the image you can use the moveRel and click functions. In my other video you'll find how to use moveRel function.

    • @afnanahmad4266
      @afnanahmad4266 2 роки тому

      @@coding101withsteve8 Yeah I understood now!💗 thanks!

  • @Rasulov_pubgm_
    @Rasulov_pubgm_ 8 місяців тому +1

    Luck bro

  • @JaySMeena
    @JaySMeena Рік тому

    How can convert this project into .exe format... Like other software?

  • @gameplaysc7644
    @gameplaysc7644 7 місяців тому

    How search pixel in inactive windows ? And if not error level , send anyone key??

  • @aivannecabrera3523
    @aivannecabrera3523 2 роки тому

    I've always wanted to make soft but every ti I download software to do so, I just look at the 5,000 buttons/settings, cry for a few

  • @daaduindustries
    @daaduindustries 2 роки тому +1

    I have a project to automate my PC. Can you take it up ? Please let know

    • @coding101withsteve8
      @coding101withsteve8  Рік тому

      Let me know!

    • @daaduindustries
      @daaduindustries Рік тому

      @@coding101withsteve8 how can i get in touch ? Some mail id ?

    • @coding101withsteve8
      @coding101withsteve8  Рік тому

      @@daaduindustries you can check my video on utube views bot in that it's mentioned. At 5:30
      Can't send in the comments.

  • @aditokta8842
    @aditokta8842 Рік тому

    when i move the window, it becomes defocused

  • @InstaSnips
    @InstaSnips 7 місяців тому

    hello im confused on what to do because the terminal is telling me this. Failed to read youtube_search.png because file is missing, has improper permissions, or is an unsupported or invalid format. what do you suggest doing?

    • @coding101withsteve8
      @coding101withsteve8  7 місяців тому

      Hello,
      Check if the file is in the same folder as your python file.

    • @InstaSnips
      @InstaSnips 7 місяців тому

      thank you i fixed it and its working now!@@coding101withsteve8

  • @bhavyapriya.n439
    @bhavyapriya.n439 Рік тому

    It is not directing to the chrome first

  • @yippykayyay
    @yippykayyay Рік тому

    hmm, @2:04 I can't run the program unless I kill the arrow key in the upper right.
    Typing python pyautogui_imp.py does nothing.
    new to coding, would love to understand why that is happening

    • @stupid_idiot_69420
      @stupid_idiot_69420 Рік тому

      also its good to provide errors when you're asking for help so i would recommend you do that next time :)

    • @stupid_idiot_69420
      @stupid_idiot_69420 Рік тому

      my comments didnt go through lol

  • @okelaquocan2485
    @okelaquocan2485 Рік тому

    Can the pyautogui locateonscreen auto click VPN unlimited App?Can you help me?😢

  • @cheetahsflame1279
    @cheetahsflame1279 Рік тому

    doesnt work when i try it it just says "no such file or directory: 'edit.png'

    • @coding101withsteve8
      @coding101withsteve8  Рік тому +1

      Hello, this error usually comes when the image file is not in the same folder as your python file or if you change the original extension of the image file.

  • @drizzersilverberg
    @drizzersilverberg 10 місяців тому

    anyone know how to deploy pyautogui script in remote server and execute it via ssh? because I got display error.

  • @syedbaba3815
    @syedbaba3815 Рік тому

    returning me in C:\Users\syeds\Desktop> python .\pyautogui_imp.py
    None
    why non and why not returing like you?

  • @Playlista567
    @Playlista567 Місяць тому

    Screenshot driven development

  • @Fungus2meelion
    @Fungus2meelion Рік тому

    This was typed with python and finished by me.

  • @ahmarzaman8750
    @ahmarzaman8750 6 місяців тому

    ❤👍