AutoPercenty3/test/img_test1.py

28 lines
991 B
Python

import random
from PIL import ImageGrab
def capture_test_screenshots(num_images=5):
# Chrome 창이 1280x720으로 실행 중일 때 중심에서 약간 오른쪽 위
# (예시 좌표: 중심에서 오른쪽 위로 약간 이동한 지점)
base_x, base_y = 400, 140 # 중심에서 약간 오른쪽 위
for i in range(num_images):
# 위치를 약간씩 조정
offset_x = random.randint(-20, 20)
offset_y = random.randint(-20, 20)
left = base_x + offset_x
top = base_y + offset_y
right = left + 440
bottom = top + 200
# 스크린샷 찍기
screenshot = ImageGrab.grab(bbox=(left, top, right, bottom))
# 파일로 저장
screenshot.save(f'test_screenshot_{i+1}.png')
print(f"스크린샷 {i+1} 저장 완료: 위치=({left}, {top}, {right}, {bottom})")
# 사용 예제: 5개의 테스트 스크린샷 저장
capture_test_screenshots(num_images=5)