1

I wrote a script to play a videogame. This script has worked perfectly on my previous Windows machine and on a Mac as well.

However, when I tried to use it today, it failed. When I looked into what was happening, the colors it was sampling from the screen were way off from what I thought they should be.

So, I downloaded Color Cop in order to look at the pixels on my screen. Color Cop should work so that the color it's showing is the color directly under my cursor. However, when I use Color Cop, the color that is displayed is always above and to the left of my cursor.

To make things even more fascinating, the more "down and to the right" my mouse is, the worse the effect is. Near the top-left of my screen the color picker works nearly perfectly.

What's going on? Why are these programs that try to detect color on the screen failing to correctly detect where my mouse is on the screen?

In case it helps, my script uses the Pillow fork of the PIL library, uses PIL to take a screenshot, and then uses pynput to detect where the mouse is. I've been able to verify that the screenshots look completely normal, and the program is able to move my mouse to the correct places on the screen. However, the part that goes to the mouse's position on the screenshot is coming up with different colors than I would expect. (And the fact that Color Cop also fails makes me think it's not my program - it's likely some setting on my computer.)

For example: Mouse out of sync

Notice that my mouse is on the "m" in "mouse" and yet the color picker thinks I'm on the "u" in superuser.

And, as we go further down and to the right, it gets worse: Another mouse out of sync

Notice that my mouse is on the word "my" in the bottom right of my question, but the color picker thinks I'm on the word "color" above and to the left. (Which is way further off than the "m" to "u" case above.)

5
  • 1
    First thing that comes in my mind - have you enabled Windows hi-dpi scaling? Reason why I'm asking is that I remember few months ago somebody complaining about the software that was supposed to read the color of the pixels at the edge of the display (to drive the ambilight LED strips behind the monitor) glitching. After some debugging it turned out that glitch only happens when Windows scaling is enabled - pixels 'seemingly' at the edges of the screen was actually shifted.
    – Artanis
    Apr 9, 2020 at 7:55
  • I'm letting Windows fix blurry apps. Still looking up how to check hi-dpi scaling.
    – Pro Q
    Apr 9, 2020 at 15:59
  • My "Change the size of text, apps, and other items" is at "125% (Recommended)"
    – Pro Q
    Apr 9, 2020 at 16:02
  • Changing that "Change the size of text, apps, and other items" setting to "100%" fixed the color picker. If you'd like to post that as an answer, I will accept. (I haven't tested out my script yet, but that's not the goal of this question, and I think this will fix it.)
    – Pro Q
    Apr 9, 2020 at 16:12
  • (It did fix the script as well, so that was definitely the issue for me.)
    – Pro Q
    Apr 9, 2020 at 17:18

0

You must log in to answer this question.

Browse other questions tagged .