Sign in to follow this  
Followers 0
skituljko

Autoit PixelGetColor of background window

5 posts in this topic

Ok so i made pretty good Eve Online mining / Hauling / Ratting script with AutoIt. The script is perfect for my needs but with one major flaw: Eve window must be active for function PixelGetColor to read pixels. 

When looking at PixelGetColor (

Please login or register to see this link.

) you can see it has an optional parameter of setting window handle for the window the pixel is being read from. Thus it is logical to me that it is possible to read pixels from windows that are not focused (i.e not minimized, but behind another window).

But having tried numerous times, i can't get it to work like i need it to. 

Am i wrong? Does the function only read visible pixels only? Why the window handle option then? And if so, is there any other method you could recommend (that also involves pixel recognition)

Share this post


Link to post
Share on other sites

PixelGetColor only works on visible windows

the handle option is to declare the coords, like search only in that specific window or on the whole desktop

 

this should work:

#include <winapi.au3>$handle = WinGetHandle(">Insert Handle Here<")MsgBox(64,"test","MemoryReadPixel color returned : " & MemoryReadPixel(400, 500, $handle) )Func MemoryReadPixel($x, $y, $handle)   Local $hDC   Local $iColor   Local $sColor   $hDC = _WinAPI_GetWindowDC($handle)   $iColor = DllCall("gdi32.dll", "int", "GetPixel", "int", $hDC, "int", $x, "int", $y)   $sColor = Hex($iColor[0], 6)   _WinAPI_ReleaseDC($handle, $hDC)   Return Hex("0x" & StringRight($sColor, 2) & StringMid($sColor, 3, 2) & StringLeft($sColor, 2))EndFunc ;==>MemoryReadPixel

Share this post


Link to post
Share on other sites

 

PixelGetColor only works on visible windows

the handle option is to declare the coords, like search only in that specific window or on the whole desktop

 

this should work:

#include <winapi.au3>$handle = WinGetHandle(">Insert Handle Here<")MsgBox(64,"test","MemoryReadPixel color returned : " & MemoryReadPixel(400, 500, $handle) )Func MemoryReadPixel($x, $y, $handle)   Local $hDC   Local $iColor   Local $sColor   $hDC = _WinAPI_GetWindowDC($handle)   $iColor = DllCall("gdi32.dll", "int", "GetPixel", "int", $hDC, "int", $x, "int", $y)   $sColor = Hex($iColor[0], 6)   _WinAPI_ReleaseDC($handle, $hDC)   Return Hex("0x" & StringRight($sColor, 2) & StringMid($sColor, 3, 2) & StringLeft($sColor, 2))EndFunc ;==>MemoryReadPixel

 

Thanks for reply. Unfortunately, this does not work. It works well when window is in foreground, it returns correct color. But when windows is in background (not minimized, just having another active window over it) it always returns 00FFFFFF

Share this post


Link to post
Share on other sites

From what I understand you cant pixel get color or checksum on a backround window. The image is stored in a different way and recalculated when its brought back up to the foreground or some such crap. The work around i was told that actually works was a C++ dll included in autoit...

Let me know if you get this to work , also interested just dont have much "digging time" available right now.

Share this post


Link to post
Share on other sites

If MemoryReadPixel does not work for you, try this one:

Please login or register to see this link.

 

It is in german but the function is in the first spoiler and the function at itself is documented in english :)

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
Sign in to follow this  
Followers 0