python - pyautogui 不返回 RBG 值(即使我添加代码:sys.platform = '_')

问题描述 投票:0回答:1

我正在使用IDLE导入pyautogui以在Mac上使用功能

pyautogui.displayMousePosition()
,但RGB结果是
RGB: (NaN, NaN, NaN)
,我正在搜索有人在IDLE或终端上向以下代码建议的解决方案:

import sys 
sys.platform = '_'

但它导致其他错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyautogui/__init__.py", line 1747, in displayMousePosition
    pixelColor = pyscreeze.screenshot().getpixel(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyscreeze/__init__.py", line 477, in _screenshot_osx
    im = Image.open(tmpFilename)
NameError: name 'Image' is not defined

丹尼斯

python pyautogui
1个回答
0
投票

如果您使用 2 个显示器,它会在主显示器上显示颜色,而在第二个显示器上显示 NaN。

© www.soinside.com 2019 - 2024. All rights reserved.