Jump to content

Recommended Posts

Posted

Hello, there!

For whatever reason PixelGetColor isn't working properly on my new Laptop. I did found out what's wrong, but don't understand why it's happening. So, it seems that AutoIt is analyzing the screen as if it's upscaled and/or has a weird offset.

Here's a script that I used for testing purposes:

F8 saves the mouse position, F9 saves the color of a pixel where F8 was pressed. After that I just wave the cursor around the screen, and if the color under the cursor matches the saved one, it plays the sound.

  Reveal hidden contents

Also, here's the kind of paint images I used for testing. It turned out that PixelGetColor detects the green color in the area marked by the orange rectangle, not where it actually is.

  Reveal hidden contents

I'd really appreciate if anyone helps me with this nonsense. Thanks!

  • Moderators
Posted

endtro,

Welcome to the AutoIt forums.

This is no doubt a matter of a different display scaling on the affected computer. There are plenty of threads about this on the forum if you search.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted
  On 3/31/2021 at 8:08 PM, Melba23 said:

This is no doubt a matter of a different display scaling on the affected computer. There are plenty of threads about this on the forum if you search.

Expand  

Hey, thanks for a quick reply!

So I did looks around the forum and the most I could get is to multiply my PixelGetColor coordinates by the scale factor. I did a bit of testing and unfortunately it doesn't seem like it's gonna work pixel perfect which is an issue for me.

 

#include <WinAPIGdi.au3>

Global $scale = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth

ConsoleWrite("Scale = " & _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] & " / " & @DesktopWidth & " = " & $scale & @CRLF)

Found this bit of code above by Malkey and tried to use it like this:

PixelGetColor($pos[0] * $scale, $pos[1] * $scale)

It does work for the most part, but not accurate enough. I tried to round the coordinates up and down as well but to no avail.

 

Any other advises?

I don't mean no disrespect, but do you know if AutoHotKey have this kind of an issue? :)

 

  • Developers
Posted
  On 3/31/2021 at 9:17 PM, endtro said:

but do you know if AutoHotKey have this kind of an issue?

Expand  

Understand you don't mean to disrespect ...but this is not the smartest question in these forums and would advice you to go there. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
  On 4/1/2021 at 3:01 AM, rednaxela said:

I had the same inssue and i decided make pixelsearch very small areas searching the same colors. That solved the problem of multiple computers.

Expand  

That's actually a great idea! I've only noticed it occasionally skipping horizontal lines of pixels. I'm gonna have to check if it also skips vertical lines. Maybe I'll be able to get away with scanning 1x3 areas around the mouse cursor.

Thanks!

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...