кому интересно нужно просто обявить размер через перпеменную и параметр мон внести в цикл
import cv2
import mss
import numpy as np
top = 200
left = 700
def screen_r():
while True:
mon = {"top": top, "left": left, "width": 700, "height": 500 }
title = "Bot Version 2.2"
fps = 0
sct = mss.mss()
last_time = time.time()
img = np.asarray(sct.grab(mon))
fps += 1
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
lower_red = np.array([0,215,245])
upper_red = np.array([0,215,245])
mask0 = cv2.inRange(hsv, lower_red, upper_red)
hasRed = np.sum(mask0)
if hasRed > 0:
mon = {"top": 690, "left": 510, "width": 200, "height": 200 }
title = "Bot Version 2.2"
sct = mss.mss()
last_time = time.time()
time.sleep(120)
else:
mon = {"top": 400, "left": 450, "width": 700, "height": 500 }
title = "Bot Version 2.2"
fps += 1
sct = mss.mss()
last_time = time.time()
cv2.imshow(title, img)
if cv2.waitKey(25) & 0xff == ord("q"):
cv2.destroyAllWindows()
break
return fps
print("mss:", screen_r())