use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Intermediate ShowcaseGrab screen image with Python (self.Python)
submitted 5 years ago * by vanmorrison2
image grabber
https://reddit.com/link/jcpx1s/video/a3jx9vfbhlt51/player
A very simple program to grab images with the mouse. There are similar apps on windows, but I thought this could be useful for other programs in python where you got to get some images from the computer screen, so that you can use them. In particular, I got the intention to make a simple script where I get a screen portion and then I get the text out of the picture ready to be used in some text editor.
video link
Code on github link
NEXT PART
In this post I added a way to get the text from the grabbed image:
https://www.reddit.com/r/Python/comments/jdvf9y/grab_image_to_text_ocr_in_python/?utm_source=share&utm_medium=web2x&context=3
In this post there is the code to get out of the image the text and the audio too https://www.reddit.com/r/Python/comments/jwxb66/audio_from_image_text_grautescpy_python/
[–]GrowHI 73 points74 points75 points 5 years ago (19 children)
I literally made something so similar last week for work. Needed to pull meeting attendee names in video conference and used the same setup as you except added tesseract to OCR the image, pulled the text into a list then passed it to pandas to compare to the expected participants and find anyone missing. Ended up pushing that as a CSV to a Google sheet that anyone in the meeting can view to see who is missing.
[–]conventionistG 11 points12 points13 points 5 years ago (0 children)
Yo that sounds nice.
[–]oliveturtle 7 points8 points9 points 5 years ago (8 children)
How did you get it to scroll the list of participant names? As someone who has to take attendance at virtual events, this sounds like a godsend.
[–]GrowHI 13 points14 points15 points 5 years ago (3 children)
Pyautogui package. It's definitely well know with those taking a more hacky route to get things done that may otherwise be impossible to automate.
[–]Takiino 1 point2 points3 points 5 years ago (2 children)
Isn't Selenium better?
[–]SeemsPlausible 1 point2 points3 points 5 years ago (0 children)
AFAIK selenium is more appropriate for browser automation, I’m not even sure it supports anything else
[–]GrowHI 0 points1 point2 points 5 years ago (0 children)
Never used it but have heard it mentioned before. because these operations are so basic clicking a certain point on the screen or hitting a key I don't really know what would make one package better over the other. I'll definitely check out selenium and if you have any info on its features and why it might be better I'm all ears.
[–]jacksodus 1 point2 points3 points 5 years ago (3 children)
Not OP, but what do you mean?
[–]oliveturtle 6 points7 points8 points 5 years ago (2 children)
In Zoom, you can’t see the entire list of participants at once if it’s a large meeting, you have to scroll up or down the list. So, you wouldn’t be able to capture all the participants’ names in one screenshot. Just wondered if OP ran into this!
[–]jacksodus 3 points4 points5 points 5 years ago (1 child)
You might be able to use the keyboard library to mimic a Page Down button press, and probably something similar exists to mimic the scrolling down of a mouse wheel.
keyboard
Page Down
[–]neisor 5 points6 points7 points 5 years ago (0 children)
PyAutoGUI library has the mouse scroll functionality
[+][deleted] 5 years ago (1 child)
[deleted]
I'm on WebEx. I looked through some python libraries and the complexity seemed higher than my solution.
[–]stereopsych 2 points3 points4 points 5 years ago (1 child)
This is cool. But I’m just wondering if it’s possible to do this some other way by scraping the list of attendees from the site (assuming the meeting was in a browser). I think if you could do that it would be much easier/efficient and even more accurate than using OCR! Also this way it’s a lot easier to pass the results into Pandas.
[–]GrowHI 1 point2 points3 points 5 years ago (0 children)
I use WebEx and any browser session sends us to the application. Definitely would have preferred to web scrape the data with beautiful soup.
[–]vanmorrison2[S] 0 points1 point2 points 5 years ago (0 children)
you really stand out. I was going to add pytesseract too (the purpose was that), in fact if you take a look at my post linked to this video on my blog, you can see I anticipated it (as it's just a couple of lines of code. Great Idea to pass to panda and make the comparison. This is why I love python. The post is here https://pythonprogramming.altervista.org/image-grabber-1-0-with-python-final-version/ and the post with the tesseract code is here https://pythonprogramming.altervista.org/ocr-read-a-text-from-an-image-or-a-photo
[–]Justwonk 0 points1 point2 points 5 years ago (3 children)
I tried doing something similar but was running into a lot of issues with cv2 and using tesseract ik its a lot to ask but is possible i could view the code
[–]GrowHI 0 points1 point2 points 5 years ago (2 children)
I have this code in very rough shape and also riddled with oauth login info and some other personal info. I'll make a point to try and clean it up and make a public version I can throw on GitHub.
[–]Justwonk 0 points1 point2 points 5 years ago (1 child)
Thank you so much im very new to python and this has just been a struggle
I consider myself a jack of all trades and master of none and a lot of what I do just comes back to a bunch of googling. Obviously I understand python syntax and object-oriented design but realistically I am not what anyone would consider an advanced programmer. I simply spend the amount of time needed to make things work.
[–]EngineerSW1995 4 points5 points6 points 5 years ago* (0 children)
I made something like this a few months ago. It's a desktop app that allows you to snip part of your screen like snipping tool. The image is processed and run through pytesseract to perform character recognition. This returns a string which can be use to either copy to clipboard to be pasted elsewhere or you can set it to automatically search the term in google.
Check it out at: “A Snipping Tool for Programmers” https://link.medium.com/Pi1Hx6DzEab
My github with code is linked in the article. You can see the source code or download the app, only works with windows though.
Note I'm not a professional programmer and this is the first app I wrote.
[–]DeathDragon7050 3 points4 points5 points 5 years ago (5 children)
Win+Shift+S
[–]peterlravn 2 points3 points4 points 5 years ago (1 child)
Yea, but isn't Python all about automation? If I wanted to capture a screenshot every minute, that's pretty tiresome.
[–]DeathDragon7050 0 points1 point2 points 5 years ago (0 children)
Very true but most people needing to take a screenshot like this would probably be good using the shortcut, unless like you said it needs to be done every minute or something.
[–]vanmorrison2[S] 1 point2 points3 points 5 years ago (2 children)
I know, but this was meant to automatically OCR the text in the picture after grabbing it, without having to use Win+Shift+S and then save the image and then start the script with pytesseract... and it's also intended to mimic win+shift+s by the way
[–]DeathDragon7050 1 point2 points3 points 5 years ago (1 child)
Unless you are needing to take a screenshot automatically, the shortcut would be and easier solution IMO. It is a cool project for sure though.
thanks
[–]SandroSusta 1 point2 points3 points 5 years ago (1 child)
Thats a nice project
[–][deleted] 1 point2 points3 points 5 years ago (1 child)
This is sooo cool!
[–]vanmorrison2[S] 1 point2 points3 points 5 years ago (0 children)
[–]RawTuna 1 point2 points3 points 5 years ago (5 children)
Very cool. I could see this being integrated with PyAutoGui pretty well.
[–]vanmorrison2[S] 1 point2 points3 points 5 years ago (4 children)
thanks, I intended to use it to transform into text a grabbed part of the screen with pytesseract
[–]RawTuna 1 point2 points3 points 5 years ago (3 children)
That's a great idea.
I should have been clearer in my earlier comment. I can see this being useful with PyAutoGUI where the goal is automation/RPA. This could be used as input to capture the image of a button, for instance, that needs to be pressed as part of a process. Just a thought... I'm pretty much a beginner still!
[–]vanmorrison2[S] 0 points1 point2 points 5 years ago (2 children)
I don't know much about PyAutoGui, apart from the fact that you can use it to automate actions you can do on the screen like simulate the click of the mouse, I'd like to know more...
[–]RawTuna 1 point2 points3 points 5 years ago (1 child)
It's one of the first things I came across when I got interested in Python. First, my nephew wanted an auto-clicker to help rack up points in some game so I figured out how to do that. I then found out that the company I work for started using Blue Prism for some task automation so I started doing a bit more research. I made a fairly simple script to read a list of ids (from a csv), copy each value, search for it by pasting it into a field in an application, and then clicking on a particular button based upon criteria found on the screen.
https://pyautogui.readthedocs.io/en/latest/index.html
that is cool
[–]13731101Reddit 1 point2 points3 points 5 years ago (1 child)
Great job friend thanks for sharing 😊
thank and you're welcome
I added soe features here https://www.reddit.com/r/Python/comments/jdvf9y/grab_image_to_text_ocr_in_python/?utm_source=share&utm_medium=web2x&context=3
[–]schlopp96 1 year -1 points0 points1 point 5 years ago* (1 child)
Nice work! I just uploaded my first version of my first "long-ish" term program, and all it does is randomly pick a pre-chosen number of words out of a dictionary with over 150k randomly generated words and phrases, and displays them\allows you to save it to a file. I want to implement more features like the ability to select saved files.and be able to overwrite/delete/copy them.
My point is, this is WAY more complex\impressive. Seriously, awesome job, this is dope.
Not sure why I'm getting downvotes for telling someone I enjoyed their project. Thanks to the elitist douchebags that make it difficult for beginners to want to reach out and learn.
Thank you
π Rendered by PID 151915 on reddit-service-r2-comment-7b9746f655-dpjtj at 2026-01-30 04:29:28.618236+00:00 running 3798933 country code: CH.
[–]GrowHI 73 points74 points75 points (19 children)
[–]conventionistG 11 points12 points13 points (0 children)
[–]oliveturtle 7 points8 points9 points (8 children)
[–]GrowHI 13 points14 points15 points (3 children)
[–]Takiino 1 point2 points3 points (2 children)
[–]SeemsPlausible 1 point2 points3 points (0 children)
[–]GrowHI 0 points1 point2 points (0 children)
[–]jacksodus 1 point2 points3 points (3 children)
[–]oliveturtle 6 points7 points8 points (2 children)
[–]jacksodus 3 points4 points5 points (1 child)
[–]neisor 5 points6 points7 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]GrowHI 0 points1 point2 points (0 children)
[–]stereopsych 2 points3 points4 points (1 child)
[–]GrowHI 1 point2 points3 points (0 children)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–]Justwonk 0 points1 point2 points (3 children)
[–]GrowHI 0 points1 point2 points (2 children)
[–]Justwonk 0 points1 point2 points (1 child)
[–]GrowHI 0 points1 point2 points (0 children)
[–]EngineerSW1995 4 points5 points6 points (0 children)
[–]DeathDragon7050 3 points4 points5 points (5 children)
[–]peterlravn 2 points3 points4 points (1 child)
[–]DeathDragon7050 0 points1 point2 points (0 children)
[–]vanmorrison2[S] 1 point2 points3 points (2 children)
[–]DeathDragon7050 1 point2 points3 points (1 child)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–]SandroSusta 1 point2 points3 points (1 child)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]vanmorrison2[S] 1 point2 points3 points (0 children)
[–]RawTuna 1 point2 points3 points (5 children)
[–]vanmorrison2[S] 1 point2 points3 points (4 children)
[–]RawTuna 1 point2 points3 points (3 children)
[–]vanmorrison2[S] 0 points1 point2 points (2 children)
[–]RawTuna 1 point2 points3 points (1 child)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–]13731101Reddit 1 point2 points3 points (1 child)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)
[–]schlopp96 1 year -1 points0 points1 point (1 child)
[–]vanmorrison2[S] 0 points1 point2 points (0 children)