import mss import numpy as np

with mss.mss() as sct: monitor = {'top': top + 1, 'left': left + 1, 'width': right - (left + 1), 'height': bottom - (top + 1)} pic = np.array(sct.grab(monitor))

使用 mss 库替代 ImageGrab 抓取屏幕截图