Jump to content

PixelGetColor and Coordinates


Go to solution Solved by thepopol777,

Recommended Posts

( Argh I lost my very old account here, can't remember what my username  was, have to start from fresh 😅 )

 

Hi guys, I have a hard time figuring out what's the catch with my PixelGetColor attempt. I know that there is a workaround for scaled screens, and having a 3840x2160 with 200% scale, I used to put a *2 on each coordinates that AI Window Info was returning. So far so good.

But today, I can't achieve to get the right spot I need. You can take a look to the attached snapshot.

The blue rectangle is the AI Window Info zone, the red spot is what I need to get ( dark blue color = 094171 ). 
While using AI Window Info, if I put the target on the spot, it returns 562 x 449, but the magnify zone shows white ( normal ).

If I try to find the spot with the magnified zone, I find it around the green cross, at 1123 x 699 ( which is *2 , as usual ).

But when I run my script, it returns me the color 606577

I tried to set my screen to 100% scale, and in this configuration the spot is at 1521 x 801. Tried to pick this spot to confirm it, while staying at 100%, and again it returns 606577 😵

 

Do you guys have any idea of what I'm missing here ?

Thank you !

 

$posX = 562
    $posY = 349
    $color = PixelGetColor($posX *2, $posY *2)
    MsgBox(0,"Test", "Color= "&$color)


PS: I'm using this way to get which checkboxes are checked or not.

screen_getColor.png

Link to comment
Share on other sites

Link to comment
Share on other sites

I don't know, I use the tool all the time and it is always working as expected.  Maybe you are better off the pixel approach, and try to identify the controls (look at UIAutomation if au3info tool cannot find them)

Link to comment
Share on other sites

put this at the top of the script, maybe it will help you

#include <WinAPISys.au3> ;***
ConsoleWrite(_WinAPI_GetSystemMetrics(78) & " x " & _WinAPI_GetSystemMetrics(79) & @CRLF) ;***
If @AutoItX64 Then Exit MsgBox(262144 + 64, StringTrimRight(@ScriptName, 4), "Please run as 32bit", 60)
DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2
ConsoleWrite(_WinAPI_GetSystemMetrics(78) & " x " & _WinAPI_GetSystemMetrics(79) & @CRLF) ;***

The ;΄*** are not needed, they are just for information

I know that I know nothing

Link to comment
Share on other sites

26 minutes ago, ioa747 said:

put this at the top of the script, maybe it will help you

#include <WinAPISys.au3> ;***
ConsoleWrite(_WinAPI_GetSystemMetrics(78) & " x " & _WinAPI_GetSystemMetrics(79) & @CRLF) ;***
If @AutoItX64 Then Exit MsgBox(262144 + 64, StringTrimRight(@ScriptName, 4), "Please run as 32bit", 60)
DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2
ConsoleWrite(_WinAPI_GetSystemMetrics(78) & " x " & _WinAPI_GetSystemMetrics(79) & @CRLF) ;***

The ;΄*** are not needed, they are just for information

 

 

Hey ioa, thank you.

I tried but it returns the same 606577 wrong color ( and console prints 1920 x 1080, 3840 x 2160 ).

I tried to run this to find something, positioning the mouse at the exact same spot than the red arrow on my first screenshot:

$pos = MouseGetPos()
$col = PixelGetColor($pos[0]* 2, $pos[1]* 2)

MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1] & "," & Hex($col))

And this returns '570, 350, 00094171' ( same coords I'm manually giving in the other script, returns good color ), it's driving me crazy 🤪

 

@Nine Same! using this for years now and I never had any problem like that

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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