import cv2
import pyautogui as p
import numpy as np
import keyboard
import time

# 캡처할 영역 (X, Y, Width, Height)
# capture_region = (608, 56, 1260, 931)  # 원하는 좌표로 변경

def draw_rectangle(page):
  
  top_left = (600, 56)
  bottom_right = (1260, 931)
  p.screenshot(imageFilename="s파이토치와 유니티 ML-Agent로 배우는 강화학습_목차_"+ str(page).zfill(4) + ".png")

            # , region=(top_left[0], top_left[1] bottom_right[0] - top_left[0], bottom_right[1] - top_left[1]))
# 핫키 설정 (s 키를 누르면 캡처 및 사각형 표시)

# 무한 루프 (q 키로 종료)
def goRoutine():
  page = 1
  while True:
      if keyboard.is_pressed("q"):
          # cv2.destroyAllWindows()
          break
      else:
        draw_rectangle(page)
        p.press('right')
        page += 1

# keyboard.add_hotkey("s", goRoutine)
keyboard.add_hotkey("s", draw_rectangle(1))
print("프로그램 실행 중... (s: 화면 표시, q: 종료)")
while True:
  if keyboard.is_pressed("q"):
      # cv2.destroyAllWindows()
      break
  else :
     time.sleep(5)
     a = p.confirm(text='내용입니다', title='제목입니다', buttons=[True, False])
     print(a)
     if a:
      goRoutine()

+ Recent posts