Sign in to follow this  
Followers 0
flatt83

Problem with _ScreenCapture_CaptureWnd

2 posts in this topic

Hi,

I'm tryin to use _ScreenCapture_CaptureWnd() to get a partial screenshot of a program, but somehow if the window is minimized it produces 0 and if in background of a other window it gets the colors of the window in front when i'm using _GDIPlus_BitmapGetPixel().

#include <screencapture.au3>
#include <GDIPlus.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>

Local $hFileOpen
Local $hBitmap
Local $p1
Local $p2
Local $Color
Local $update[40][10]
Local $sFilePath



$sFilePath = "C:\Users\tobias\Desktop\Update.txt"
$hFileOpen = FileOpen($sFilePath, $FO_APPEND)

_GDIPlus_Startup()

$hwnd = WinGetHandle("Curse Client")
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP( _ScreenCapture_CaptureWnd("", $hwnd))

For $iX = 492 To 531 Step 1
    For $iY = 262 To 271 Step 1
        $Color = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)
        $p1 = $iX - 492
        $p2 = $iY - 262
        $update[$p1][$p2] = $Color
        FileWriteLine($hFileOpen, "&update[" & $ix - 1 & "][" & $iy - 1 & "] = " & $Color)
    Next
Next
FileClose($hFileOpen)
_WinAPI_DeleteObject ( $hBitmap)
_GDIPlus_Shutdown()

Share this post


Link to post
Share on other sites



Afaik you cannot capture the content of a window when it is minimized! You have to restore the window and capture it.

 

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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