pip install pyautogui
import pyautogui
import time
import os
import tkinter as tk
from tkinter import messagebox
# Folder to save screenshots
screenshot_folder = "screenshots"
if not os.path.exists(screenshot_folder):
os.makedirs(screenshot_folder)
# Function to take a screenshot
def take_screenshot():
timestamp = time.strftime("%Y-%m-%d_%H-%M-%S")
filename = os.path.join(screenshot_folder, f"screenshot_{timestamp}.png")
screenshot = pyautogui.screenshot()
screenshot.save(filename)
print(f"✅ Screenshot saved: {filename}")
# Function to start auto screenshots
def start_screenshot():
try:
interval = int(entry.get())
messagebox.showinfo("Started", f"Taking screenshots every {interval} seconds.")
while True:
take_screenshot()
time.sleep(interval)
except ValueError:
messagebox.showerror("Error", "Please enter a valid number.")
# GUI with Tkinter
root = tk.Tk()
root.title("Automated Screenshot Tool")
tk.Label(root, text="Enter Screenshot Interval (seconds):").pack()
entry = tk.Entry(root)
entry.pack()
tk.Button(root, text="Start Screenshot Capture", command=start_screenshot).pack()
tk.Button(root, text="Exit", command=root.quit).pack()
root.mainloop()
No comments:
Post a Comment