Fix crash

This commit is contained in:
AuroraWright
2025-10-12 09:16:13 +02:00
parent e262231a1d
commit f0513c22da

View File

@@ -799,10 +799,10 @@ class ScreenshotThread(threading.Thread):
self.screencapture_mode = 2 self.screencapture_mode = 2
if self.screencapture_mode != 2: if self.screencapture_mode != 2:
sct = mss.mss() self.sct = mss.mss()
if self.screencapture_mode == 1: if self.screencapture_mode == 1:
mon = sct.monitors mon = self.sct.monitors
if len(mon) <= screen_capture_monitor: if len(mon) <= screen_capture_monitor:
raise ValueError('Invalid monitor number in screen_capture_area') raise ValueError('Invalid monitor number in screen_capture_area')
coord_left = mon[screen_capture_monitor]['left'] coord_left = mon[screen_capture_monitor]['left']
@@ -1051,7 +1051,7 @@ class ScreenshotThread(threading.Thread):
else: else:
img = img.crop(self.window_area_coordinates[1]) img = img.crop(self.window_area_coordinates[1])
else: else:
sct_img = sct.grab(self.sct_params) sct_img = self.sct.grab(self.sct_params)
img = Image.frombytes('RGB', sct_img.size, sct_img.bgra, 'raw', 'BGRX') img = Image.frombytes('RGB', sct_img.size, sct_img.bgra, 'raw', 'BGRX')
return img return img
@@ -1105,7 +1105,7 @@ class ScreenshotThread(threading.Thread):
def run(self): def run(self):
if self.screencapture_mode != 2: if self.screencapture_mode != 2:
sct = mss.mss() self.sct = mss.mss()
while not terminated: while not terminated:
if not screenshot_event.wait(timeout=0.1): if not screenshot_event.wait(timeout=0.1):
if coordinate_selector_event.is_set(): if coordinate_selector_event.is_set():