Sign in to follow this  
Followers 0
MasonMill

Window Capture

3 posts in this topic

Hey Guys,

I want to display the client window but when I use _ScreenCapture_CaptureWnd it captures the border and title bar and everything with it. Im trying to find coordinates of things relative to that client but I cant get it relative to the client becasue the window border is imaged too. I found a previous topic on the forums but the question was never answered. Any ideas?

This is how I changed the example within the help file:

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic, $hImage, $iX, $iY, $hClone, $fileloc=@ScriptDir&"\SOMEclient.bmp",$iLeft,$iTop,$iRight,$iBottom,$bCursor

    ; Create GUI
    $hGUI = GUICreate("GDI+", $ClientSize[0], $ClientSize[1])
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Capture 32 bit bitmap
    ;$hBMP = _ScreenCapture_Capture("")
    $hBMP = _ScreenCapture_CaptureWnd ( "" , $hSOMEclientWin ); MY AUGMENTATION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)

    ; Create 24 bit bitmap clone
    $iX = _GDIPlus_ImageGetWidth($hImage)
    $iY = _GDIPlus_ImageGetHeight($hImage)
    $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iX, $iY, $GDIP_PXF24RGB)

    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hClone, @ScriptDir & "\GDIPlus_Image.bmp")

    ; Clean up resources
    _GDIPlus_BitmapDispose($hClone)
    _GDIPlus_BitmapDispose($hImage)
    _WinAPI_DeleteObject($hBMP)

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\GDIPlus_Image.bmp")
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0)

    ; Clean up resources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_BitmapDispose($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Thanks,

Mason

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How do you know what the client window is?

You can enumerate all open visible windows, search for client window and pass the handle to _ScreenCapture_CaptureWnd.
 

#include <Array.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

GetAllWindow()

Func GetAllWindow() ;code by Authenticity - modified by UEZ
    Local $aWin = WinList(), $aWindows[1][4]
    Local $iStyle, $iEx_Style, $iCounter = 0
    Local $i, $aWinPos

    For $i = 1 To $aWin[0][0]
        $iEx_Style = BitAND(_WinAPI_GetWindowLong($aWin[$i][1], $GWL_EXSTYLE), $WS_EX_TOOLWINDOW)
        $iStyle = BitAND(WinGetState(HWnd($aWin[$i][1])), 2)
        If $iEx_Style <> -1 And Not $iEx_Style And $iStyle Then
            $aWinPos = WinGetPos($aWin[$i][1])
            If $aWinPos[2] > 1 And $aWinPos[3] > 1 Then
                $aWindows[$iCounter][0] = $aWin[$i][0]
                $aWindows[$iCounter][1] = $aWin[$i][1]
                $aWindows[$iCounter][2] = $aWinPos[2]
                $aWindows[$iCounter][3] = $aWinPos[3]
                $iCounter += 1
            EndIf
            ReDim $aWindows[$iCounter + 1][4]
        EndIf
    Next
    ReDim $aWindows[$iCounter][4]
    _ArrayDisplay($aWindows)
    Return $aWindows
EndFunc   ;==>GetAllWindow

Br,
UEZ

Edited by 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

Ahh, you have to define the style of window. Thank you very much!

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