Jump to content

Pixel Color from screenshot?


Recommended Posts

Hey all. Ive been trying to find a way to get pixel information, more specifically it's color, at a coordinate of a screenshot stored in memory. Im using the _ScreenCapture_... functions, and I simply cant find a way to do it. I know there are other alternatives, such as creating a GUI that is the same size as the desktop and pasting it on there, but it still doesn't work for me. Too bulky, and ugly.

Any help would be greatly appreciated.

Thanks!

-Monkey

Monkeh.

Link to comment
Share on other sites

Hi! Don`t sure, that this work correctly, but try:

#include <GDIPlus.au3>
#include <ScreenCapture.au3>

_GDIPlus_Startup()

$hBMP = _ScreenCapture_Capture("")
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

If $hBitmap = 0 Then
    MsgBox(16, "Bitmap Create", "Error")
    Exit
EndIf

$hDC = _WinAPI_GetDC("")

$aRet = DllCall("gdi32.dll", "int", "GetPixel", "hwnd", $hDC, "int", 100, "int", 100)

ConsoleWrite("0x" & Hex($aRet[0], 6) & @LF)

_WinAPI_ReleaseDC(0, $hDC)
_GDIPlus_ImageDispose($hBitmap)
_WinAPI_DeleteObject($hBMP)

_GDIPlus_Shutdown()

Note: The return value is the RGB value of the pixel

Edited by rasim
Link to comment
Share on other sites

Thanks a bunch - it worked, but not for what I need, and its not you, its this program. It prevents you from getting pixel colors from the screen while its running - its basically a game protector app.

perhaps there is a way to get it from a saved file? I could then just use the screencapture save to file command.

Thanks!

Monkeh.

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...