在嘗試查看屏幕上的像素是否與 RGB 顏色匹配時遇到問題。但是,即使經過調整,我也無法獲得任何好的結果。我在網上查找并嘗試了不同的解決方案,但沒有運氣。Exception in thread Thread-2:Traceback (most recent call last): File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "C:\Python38\lib\site-packages\keyboard\_generic.py", line 58, in process if self.pre_process_event(event): File "C:\Python38\lib\site-packages\keyboard\__init__.py", line 218, in pre_process_event callback(event) File "C:\Python38\lib\site-packages\keyboard\__init__.py", line 649, in <lambda> handler = lambda e: (event_type == KEY_DOWN and e.event_type == KEY_UP and e.scan_code in _logically_pressed_keys) or (event_type == e.event_type and callback()) File "main.py", line 101, in bomb_timer pix = pyautogui.pixelMatchesColor(959, 83, (169, 0, 0), tolerance=61) File "C:\Python38\lib\site-packages\pyscreeze\__init__.py", line 559, in pixelMatchesColor pix = pixel(x, y) File "C:\Python38\lib\site-packages\pyscreeze\__init__.py", line 584, in pixel return (r, g, b) File "C:\Python38\lib\contextlib.py", line 120, in __exit__ next(self.gen) File "C:\Python38\lib\site-packages\pyscreeze\__init__.py", line 113, in __win32_openDC raise WindowsError("windll.user32.ReleaseDC failed : return 0")OSError: windll.user32.ReleaseDC failed : return 0我的代碼:def clock_timer(): clock = pyautogui.locateCenterOnScreen('assets/clock2.png', grayscale=True, confidence=0.5, region=(920,10, 90, 90)) print(Style.RESET_ALL + "[" + Fore.RED + "zVal" + Style.RESET_ALL + "]" + Fore.RED + " Waiting for clock...") while clock == None: clock1 = pyautogui.locateCenterOnScreen('assets/clock2.png', grayscale=True, confidence=0.5, region=(920,10, 90, 90)) pix = pyautogui.pixelMatchesColor(959, 83, (169, 0, 0), tolerance=61) #PART THAT DOESNT WORK if clock1 != None and pix == True: clock = "Stop loop"
添加回答
舉報
0/150
提交
取消