Jump to content
Sign in to follow this  
fgthhhh

Captures a screen shot of a specified HIDDEN window

Recommended Posts

fgthhhh

_ScreenCapture_CaptureWnd can capture a image with coordinate but it don't work with hidden window.

i found in forum a way to capture a full hidden window but i don't know how to do it with coordinate( here )

can any1 know how to 'Captures a screen shot of a specified HIDDEN window'

thx

Share this post


Link to post
Share on other sites
fgthhhh

UP FOR AN ANSWER

Share this post


Link to post
Share on other sites
fgthhhh

this is my code. it would capture hidden window but can't do with minimize window

i don't know why but sometime it can capture a specific coordinate, sometime it don't work

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

_GDIPlus_Startup()

$hWnd = WinGetHandle("my bot")


$hBMP = _Capture( $hWnd, 100, 100, 200, 200)



Func _CaptureWnd( $hWnd, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1)
    Local $tRect = _WinAPI_GetWindowRect($hWnd)
    $iLeft += DllStructGetData($tRect, "Left")
    $iTop += DllStructGetData($tRect, "Top")
    If $iRight = -1 Then $iRight = DllStructGetData($tRect, "Right") - DllStructGetData($tRect, "Left")
    If $iBottom = -1 Then $iBottom = DllStructGetData($tRect, "Bottom") - DllStructGetData($tRect, "Top")
    $iRight += DllStructGetData($tRect, "Left")
    $iBottom += DllStructGetData($tRect, "Top")
    If $iLeft > DllStructGetData($tRect, "Right") Then $iLeft = DllStructGetData($tRect, "Left")
    If $iTop > DllStructGetData($tRect, "Bottom") Then $iTop = DllStructGetData($tRect, "Top")
    If $iRight > DllStructGetData($tRect, "Right") Then $iRight = DllStructGetData($tRect, "Right")
    If $iBottom > DllStructGetData($tRect, "Bottom") Then $iBottom = DllStructGetData($tRect, "Bottom")
    Return _Capture( $hWnd, $iLeft, $iTop, $iRight, $iBottom)
EndFunc
Func _Capture( $hWnd,$iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1)
    If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN)
    If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN)
    If $iRight < $iLeft Then Return SetError(-1, 0, 0)
    If $iBottom < $iTop Then Return SetError(-2, 0, 0)

    Local $iW = ($iRight - $iLeft) + 1
    Local $iH = ($iBottom - $iTop) + 1

    Local $hDDC = _WinAPI_GetDC($hWnd)
    Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
    Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH)
    _WinAPI_SelectObject($hCDC, $hBMP)
     DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0)
    _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY)


    _WinAPI_ReleaseDC($hWnd, $hDDC)
    _WinAPI_DeleteDC($hCDC)
     _ScreenCapture_SaveImage(@ScriptDir&"\new.jpg", $hBMP, False)
    _WinAPI_DeleteObject($hBMP)
EndFunc

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  

×