Jump to content
Atzi

Pixelgetcolor and infotool seem to get wrong values

Recommended Posts

Atzi
Start ()
 Func Start ()
  WinActivate ("Neue Bitmap - Paint")
  sleep(2000)
  ConsoleWrite(Hex(PixelGetColor(721,313)) & @CR)
  
 ConsoleWrite(Hex(PixelGetColor(907,535)) & @CR)
EndFunc

Hi there.

I am new to this forum and to programming, so i could really use some help here.

No matter what mode i use in the infotool to get the coords of the pixels (window or desktop)

When i check the color valies of my script on the internet they seem to be completely different colors. Also when i use the infotool to mouseover to get  value they dont fit the colors.

If i hover over various different colors (no matter if frozen or not) the value sometimes simply doesnt change.

My OS is win10 home if that matters btw.

Really hope s1 can get me started on this.

Share this post


Link to post
Share on other sites
Bilgus

I'd check if you have DPI Scaling activated that seems to really throw stuff off in autoit 

maybe try adding #AutoIt3Wrapper_Res_HiDpi=Y to the top of your script?

Share this post


Link to post
Share on other sites
Bilgus
HotKeySet("{ESC}", "_Exit")
While 1
    MouseGetPixel()
    Sleep(1000)
WEnd

Func MouseGetPixel()
    Local Static $iLastX = 0
    Local Static $iLastY = 0
    ;WinActivate ("Neue Bitmap - Paint")
    $aPos = MouseGetPos()
    If IsArray($aPos) And ($aPos[0] <> $iLastX Or $aPos[1] <> $iLastY) Then
        ConsoleWrite(StringFormat("(%d, %d) = 0x%X", $aPos[0], $aPos[1], PixelGetColor($aPos[0], $aPos[1])) & @CRLF)
        $iLastX = $aPos[0]
        $iLastY = $aPos[1]
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc

Something that might make it a bit easier to try

Share this post


Link to post
Share on other sites
Atzi
On 13.3.2018 at 11:17 PM, Bilgus said:

I'd check if you have DPI Scaling activated that seems to really throw stuff off in autoit 

maybe try adding #AutoIt3Wrapper_Res_HiDpi=Y to the top of your script?

Hi first i wanna thank you that you are willing to help me here. Didn't have a chance to test your codes yet tho. Do you mind explaining what this exactly does? I am running @full hd if that matters because what i found searching this function it should be more suited to higher resolutions. Also is the dpi scaling your talking off sth in the graphic settings of win10?

Could it help to update the graphic drivers or doesnt this impact the get pixel in any way didnt do updates for a while as i didnt use this pc for a while :)

Edit: just had a chance to check for updates... driver is uptodate anyway. Also found out what you meant with dpi scaling and it seems to have done the trick! It now seems to show proper color/coord in windowinfo tool at least. Hope i get time to test this on code tomorrow. Thos really helped me thus far tho - thanx a lot! Scaling was 150÷ in win10 settings

Edited by Atzi

Share this post


Link to post
Share on other sites
Bilgus

If that simple workaround doesn't work then you'll need to get the resolution of the monitor your window is in and apply the proper scaling to it

like the highest DPI is 125%  so you need to take the coordinates and scale them by 125% so x = 100 becomes x= 80 y = 50 becomes (50 / 1.25)= 40 it gets to be a pain in the butt because its not alway  whole number ex x = 61 / 1.25 = 48.8 so is it pixel 48 or 49 or both?

Share this post


Link to post
Share on other sites
Atzi
18 hours ago, Bilgus said:

If that simple workaround doesn't work then you'll need to get the resolution of the monitor your window is in and apply the proper scaling to it

like the highest DPI is 125%  so you need to take the coordinates and scale them by 125% so x = 100 becomes x= 80 y = 50 becomes (50 / 1.25)= 40 it gets to be a pain in the butt because its not alway  whole number ex x = 61 / 1.25 = 48.8 so is it pixel 48 or 49 or both?

Thx for all the thoughts you put into this. I guess i will simply put scaling in win to 100% tho and hope i can work out the func this way... dont need to have it to 150% anyway cant even remember to have it set to this ;)

Will tell you if i managed to get this working once i got time to code it (hope this weekend)

Edited by Atzi

Share this post


Link to post
Share on other sites
Atzi

Seems to work now. Thx a lot!

Also had a glince into the imagefind function. Do you maybe know, if there is a way to use it inside a hwnd (doesnt matter if it has to be active for this)... i know i could just use it on desktop but there are some downsides i guess... would have to set all up with desktop coords but i would prefer to use window coords to set the area to search as it wouldnt be depending on the window location and therefore wouldnt change if window was moved. Could be an alternative for pixelsearch with less chance of false positives i guess... just in case i can hook the func to specific windows as pixelfind tho.

Share this post


Link to post
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

×