Screenshot Taker with Python

Search for a command to run...

PyAutoGUI is the best python module I have ever used. I am a Python programmer and have used many python modules like Sklearn, tkinter, pandas, numpy, matplotlib and many more but found nothing more interesting than PyAutoGUI
So good to hear from you Sannidhya Dasgupta.
I am still learning and exploring PyAutoGUI and other Python Modules.
That's great. If you face any kind of problems or have any questions feel free to ask meAyushi Rawat
Wow loved it! I always open your articles with interest to learn something new.
Thank you very much for this beautiful education. God will bless you. Extra note: You can also screenshot without specifing path name. You can do that by, From tkinter import filedialog
Sc = pyautogui.screenshot() File_path = filedialog.asksaveasfilename(defaultextension = '.png') Sc.save(file_path). Thanks. I will be waiting for your next uploads and I have subscribed to your newsletter.
Thank you 😄 Yes, that is one great method.
any plans on making beautiful twitter screenshot maker?
Thanks for sharing the knowledge Ayushi ! Always learning something new from you !!
Hi Ayushi,I was running the code and it was really great to see this solution of taking screen shots , just one thing, can we make it more dynamic for example, if i want to take second screen shot it should get saved in the same location with the name "screenshot2" without changing the code... Thanks again!!
You can add timestamp along with screenshot name using calender or time module, now you can create unique filename for every screenshot example screenshot-2020-10-19-646438.png Abhishek Mani Tripathi
Hi Praful, Can you please show the coding part of it how i can add in the existing code. Thanks again! Prafful Lachhwani
The series content will mostly cover Technical Python tutorials and my recent learnings and experience in Python.
In this Blog article, we will learn how to send Desktop notifications . We will see the implementation in Python. Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same! You can refe...
All you need to know about Hacktoberfest 2021

Hello reader! Well, Hacktoberfest is something, you are gonna hear a lot about in the coming month. You can refer to my YouTube video Tutorial to see a working tutorial for better understanding and a step-by-step guide of the same. https://www.yo...

Hello reader! In this Blog post, I will share some useful code snippets and functions in Python. Give it a read. Let's get started! 1. Memory The method getsizeof can be used to retrieve the size of any object. Here's an example of the same. import...

Hello reader! Whenever a client sends a request to the server, the response always contains a status code. You might not see it always but it's returned at every client-server interaction. Well, even if you are not a programmer, you would still know...

Hello reader! Microsoft subsidiary GitHub launched Copilot to power pair programming with AI. In this blog post, I will share all you need to know about it. You can refer to my YouTube video Tutorial to see a working tutorial for better understandin...

In this Blog article, we will see how to Capture a Screenshot . We will see the implementation in python.
Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!
You can refer to my YouTube video tutorial for better Understanding
Screenshot, also known as screen capture, is a digital image that shows the contents of a computer display. A common screenshot is created by the operating system or software running on the device. Taking, saving, and sharing screenshots can be extremely helpful.
1. PyAutoGUI Introduction
2. How to capture Screenshot using python
PyAutoGUI lets your Python scripts control the mouse and keyboard to automate interactions with other applications.
Features
If you wish to know more about it, you can refer to PyAutoGUI Documentation. Use this link to navigate to the documentation.
Now that you are aware of PyAutoGUI basics, we can move forward to the coding section.
You can find all the code at my GitHub Repository. Drop a star if you find it useful.

Open your terminal and run the following command
pip install PyAutoGUI
Now that we have the package, we are ready to import it in our python script.
import pyautogui
import tkinter as tk
Now, its time to create a canvas. Let's give it a title. I am setting Sc taker as the title using the title method. You can specify the canvas dimensions. I am setting the height and width as 300.
root= tk.Tk()
root.title('Sc taker')
canvas1 = tk.Canvas(root, width = 300, height = 300)
Now, let's pack our Canvas using the pack method.
canvas1.pack()
Now that we have our canvas ready, lets define a function to capture screenshot. I am naming it as myScreenshot.
We need to create an object to store our screenshot. I am naming it as sc. So, we will call screenshot method from PyAutoGUI on sc.
def myScreenshot():
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'C:\Users\imar\Desktop\Python Tutotial\screenshot1.png')
Let's save our screenshot using the save method,. Give proper path along with the screenshot name.
Now, let's create a button and specify few parameters.
text of the button as Take Screenshot. myScreenshot in command.Background and foreground color as green and white respectively.font as 15.myButton = tk.Button(text='Take Screenshot', command=myScreenshot, bg='green',fg='white',font= 15)
Now that our button is ready, let's put it in the center.
canvas1.create_window(150, 150, window=myButton)
At last, we will call our mainloop.
root.mainloop()
Our Python script is ready. Run the program and you will see something like this.

When you click the Take Screenshot button. A new screenshot will be captured and saved in your specified path.
That's it! simple, isn't it?
You can find all the code at my GitHub Repository. Drop a star if you find it useful.
Thank you for reading, I would love to connect with you at Twitter.
Do share your valuable feedback and suggestions!
You should definitely check out my other Blogs:
See you in my next Blog article, Take care