Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rgb for current cursor for mac #791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyautogui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,13 +1752,13 @@ def displayMousePosition(xOffset=0, yOffset=0):
# Get and print the mouse coordinates.
x, y = position()
positionStr = "X: " + str(x - xOffset).rjust(4) + " Y: " + str(y - yOffset).rjust(4)
if not onScreen(x - xOffset, y - yOffset) or sys.platform == "darwin":
# Pixel color can only be found for the primary monitor, and also not on mac due to the screenshot having the mouse cursor in the way.
if not onScreen(x - xOffset, y - yOffset):
# Pixel color can only be found for the primary monitor
#Screenshot in Mac fixed at pyscreeze
pixelColor = ("NaN", "NaN", "NaN")
else:
pixelColor = pyscreeze.screenshot().getpixel(
(x, y)
) # NOTE: On Windows & Linux, getpixel() returns a 3-integer tuple, but on macOS it returns a 4-integer tuple.
(x, y)) # NOTE: On Windows & Linux, getpixel() returns a 3-integer tuple, but on macOS it returns a 4-integer tuple.
positionStr += " RGB: (" + str(pixelColor[0]).rjust(3)
positionStr += ", " + str(pixelColor[1]).rjust(3)
positionStr += ", " + str(pixelColor[2]).rjust(3) + ")"
Expand Down