尝试查看屏幕上的像素是否与 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"