manually multiple screen
Automatic Multiple Screen
30 second por por automatc screenshot
multiple screen handle also images compress
ধাপ ১: প্রথমে Install করো
তোমার computer এ CMD বা Terminal খুলে এই command গুলো লিখো:
pip install mss
pip install Pillow
এটা দুইটা জিনিস install করবে যা screenshot নিতে লাগবে।
ধাপ ২: একদম সহজ Program
এইবার একটা Python file তৈরি করো (যেমন: screenshot.py) এবং এই code লিখো:
from mss import mss
# Screenshot নাও
with mss() as sct:
sct.shot(output='amar_screenshot.png')
print("Screenshot নেওয়া হয়ে গেছে!")
এটা কি করবে?
- পুরো screen এর screenshot নিবে
amar_screenshot.pngনামে save করবে- তোমার program যেখানে আছে সেই folder এ save হবে
একাধিক Monitor থাকলে
যদি তোমার একাধিক monitor (screen) থাকে:
from mss import mss
with mss() as sct:
# কয়টা monitor আছে দেখো
print(f"তোমার {len(sct.monitors)-1} টা monitor আছে")
# প্রথম monitor এর screenshot
sct.shot(mon=1, output='screen1.png')
# দ্বিতীয় monitor এর screenshot (যদি থাকে)
sct.shot(mon=2, output='screen2.png')
print("সব screenshot নেওয়া শেষ!")
বুঝতে সাহায্য:
mss()= এটা screenshot নেওয়ার toolshot()= এটা screenshot নেয় এবং save করেmon=1= প্রথম screenmon=2= দ্বিতীয় screenoutput='নাম.png'= যে নামে save হবে
চালাবে কিভাবে?
CMD বা Terminal এ লিখো:
python screenshot.py
ব্যাস! Screenshot নেওয়া হয়ে যাবে! 📸
আরো কিছু জানতে চাও?
from mss import mss
from mss.tools import to_png
with mss() as sct:
monitors = sct.monitors[1:] # প্রথমটি পুরো desktop, বাকি screens
print(f"Total screens: {len(monitors)}")
for i, mon in enumerate(monitors, start=1):
img = sct.grab(mon) # নিরাপদ গ্রাব
filename = f"screen_{i}.png" # আউটপুট নাম
with open(filename, "wb") as f:
f.write(to_png(img.rgb, img.size))
print(f"Saved {filename}")
import os, time, datetime
from mss import mss
from mss.tools import to_png
BASE = "screenshots"
os.makedirs(BASE, exist_ok=True)
with mss() as sct:
while True:
today = datetime.date.today().isoformat()
folder = os.path.join(BASE, today)
os.makedirs(folder, exist_ok=True)
for i, mon in enumerate(sct.monitors[1:], 1):
shot = sct.grab(mon)
path = os.path.join(folder, f"{datetime.datetime.now():%H-%M-%S}_screen{i}.png")
with open(path, "wb") as f:
f.write(to_png(shot.rgb, shot.size))
print("Captured at", datetime.datetime.now().strftime("%H:%M:%S"))
time.sleep(30)
import os
import time
import datetime
from mss import mss
from mss.exception import ScreenShotError
from PIL import Image
import io
BASE = "screenshots"
os.makedirs(BASE, exist_ok=True)
screen_map = {}
with mss() as sct:
while True:
today = datetime.date.today().isoformat()
date_folder = os.path.join(BASE, today)
os.makedirs(date_folder, exist_ok=True)
monitors = sct.monitors[1:]
current_hashes = [hash(frozenset(mon.items())) for mon in monitors]
# detect new screens
for idx, mon_hash in enumerate(current_hashes, 1):
if mon_hash not in screen_map:
folder_name = f"screen{len(screen_map)+1}"
screen_map[mon_hash] = folder_name
print(f"New screen detected → {folder_name}")
removed_hashes = [h for h in screen_map if h not in current_hashes]
for h in removed_hashes:
print(f"Screen removed → {screen_map[h]}")
del screen_map[h]
for mon, mon_hash in zip(monitors, current_hashes):
folder_name = screen_map[mon_hash]
screen_folder = os.path.join(date_folder, folder_name)
os.makedirs(screen_folder, exist_ok=True)
try:
shot = sct.grab(mon)
# convert raw RGB to PIL Image
img = Image.frombytes("RGB", shot.size, shot.rgb)
# optional: resize if needed (uncomment)
# max_width = 1920
# if img.width > max_width:
# ratio = max_width / img.width
# new_size = (max_width, int(img.height * ratio))
# img = img.resize(new_size, Image.LANCZOS)
# save as compressed WebP (smallest size, good quality)
timestamp = datetime.datetime.now().strftime("%H-%M-%S")
file_path = os.path.join(screen_folder, f"{timestamp}.webp")
img.save(file_path, "WEBP", quality=80, method=6) # quality 0-100, method=6 best compression
# alternatively, save as JPEG:
# file_path_jpeg = os.path.join(screen_folder, f"{timestamp}.jpg")
# img.save(file_path_jpeg, "JPEG", quality=85, optimize=True)
except ScreenShotError as e:
print(f"Warning: Could not capture {folder_name}: {e}")
print("Captured at", datetime.datetime.now().strftime("%H:%M:%S"))
time.sleep(30)