comradeb14ck

Screen Capture Library (User Defined Function)

32 posts in this topic

Hi there. I was wondering who wrote the Screen Capture library? I could not find anyone's name in the helpfile. Can anyone direct me to a username or email address who created this library? Thanks!

Share this post


Link to post
Share on other sites



Original author is PaulIA (author of Auto3Library).

But he has left AutoIt forum and stopped maintaining of his library.

Gary converted all Auto3Library into standard AutoIt UDF format.

If you have some problem just make post in General Help & Support forum and somebody will help you ...

Share this post


Link to post
Share on other sites

Thanks. I don't need help. I just wanted to ask the author a question.

Share this post


Link to post
Share on other sites

So ask question here :)

_ScreenCapture_CaptureWnd is merely a wrapper of _ScreenCapture_Capture and it is unable to take a screenshot of layered windows (drawn by the graphic card). I wrote a function _ScreenCapture_CaptureWnd2 that fixes this problem and I think that this should be integrated to the library, how do I proceed?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

_ScreenCapture_CaptureWnd is merely a wrapper of _ScreenCapture_Capture and it is unable to take a screenshot of layered windows (drawn by the graphic card). I wrote a function _ScreenCapture_CaptureWnd2 that fixes this problem and I think that this should be integrated to the library, how do I proceed?

As first step you can make post with that in Examples forum. But you may add posts there after some post count.

Also look here at UDF standards and informations:

http://www.autoitscript.com/forum/index.php?showtopic=62035

Send prepared function by PM to Gary.

Edited by Zedna

Share this post


Link to post
Share on other sites

I have been using it for over a year now and it works fine, so here it is:

; #FUNCTION# ====================================================================================================================
; Name...........: _ScreenCapture_CaptureWndV2
; Description ...: Captures a screen shot of a specified window. This function is an alternative to '_ScreenCapture_CaptureWnd'.
;                  It is able to take screenshots of layered windows (drawn by the graphic card). See 'remarks' below.
; Syntax.........: _ScreenCapture_CaptureWndV2($sFileName, $hWnd[, $iLeft = 0[, $iTop = 0[, $iRight = -1[, $iBottom = -1[, $fCursor = True]]]]])
; Parameters ....: $sFileName   - Full path and extension of the image file
;                  $hWnd        - Handle to the window to be captured
;                  $iLeft       - X coordinate of the upper left corner of the client rectangle
;                  $iTop        - Y coordinate of the upper left corner of the client rectangle
;                  $iRight      - X coordinate of the lower right corner of the rectangle
;                  $iBottom     - Y coordinate of the lower right corner of the rectangle
;                  $fCursor     - If True the cursor will be captured with the image
; Return values .: See remarks
; Author ........: Patryk Szczepankiewicz (pszczepa at gmail dot com)
; Modified.......:
; History .......: JAN 21, 2009 - Created
;                  OCT 18, 2010 - Commented and posted.
; Remarks .......: 1/ If FileName is not blank this function will capture the screen and save it to file. If FileName is blank, this
;                  function will capture the screen and return a HBITMAP handle to the bitmap image.  In this case, after you are
;                  finished with the bitmap you must call _WinAPI_DeleteObject to delete the bitmap handle.  All coordinates are  in
;                  client coordinate mode.
;
;                  2.1/ Layered windows do not appear on screenshots taken by '_ScreenCapture_Capture' because it uses the desktop's
;                  handle whereas the layered windows are drawn directly by the graphic card. 2.2/ '_ScreenCapture_CaptureWnd'
;                  is a wrapper of '_ScreenCapture_Capture' and, therefore, has the same limitations. 2.3/ Instead,
;                  '_ScreenCapture_CaptureWndV2', THIS FUNCTION, is using the handle of the targetted window to perfom its task
;                  (in a similar way than '_ScreenCapture_Capture'uses the Desktop's handle).
;
; Related .......: _WinAPI_DeleteObject
; Link ..........; http://www.autoitscript.com/forum/index.php?showtopic=65008
; Example .......; No
; Credits .......: Based on Paul Campbell's '_ScreenCapture_Capture' function.
; ===============================================================================================================================
Func _ScreenCapture_CaptureWndV2($sFileName, $hWnd, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
    Local $tRect
    Local Const $WINDOW_BORDER_WIDTH_OLD_STYLE = 4

    $tRect = _WinAPI_GetWindowRect($hWnd)

    ;$iLeft += DllStructGetData($tRect, "Left");REMOVED_ORIGINAL_CODE;
    ;$iTop += DllStructGetData($tRect, "Top");REMOVED_ORIGINAL_CODE;
    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");REMOVED_ORIGINAL_CODE;
    ;$iBottom += DllStructGetData($tRect, "Top");REMOVED_ORIGINAL_CODE;
    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")



    Local $iH, $iW, $hDDC, $hCDC, $hBMP, $aCursor, $aIcon, $hIcon

    $iW = $iRight - $iLeft
    $iH = $iBottom - $iTop

    ;$hWnd = _WinAPI_GetDesktopWindow();REMOVED_ORIGINAL_CODE;


    ;-------------------------- ADDED_NEW_CODE --------------------------;
    Local $tClient, $iDeltaX, $iDeltaY
    $tClient = _WinAPI_GetClientRect($hWnd)
    $iDeltaX = $iW - DllStructGetData($tClient, "Right")
    $iDeltaY = $iH - DllStructGetData($tClient, "Bottom")
    if $iDeltaX > 0 then $iLeft = $iLeft - $iDeltaX + $WINDOW_BORDER_WIDTH_OLD_STYLE
    if $iDeltaY > 0 then $iTop = $iTop - $iDeltaY + $WINDOW_BORDER_WIDTH_OLD_STYLE
    ;--------------------------------------------------------------------;


    $hDDC = _WinAPI_GetDC($hWnd)
    $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH)
    _WinAPI_SelectObject($hCDC, $hBMP)
    _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $SRCCOPY)

    If $fCursor Then
        $aCursor = _WinAPI_GetCursorInfo()
        If $aCursor[1] Then
            $hIcon = _WinAPI_CopyIcon($aCursor[2])
            $aIcon = _WinAPI_GetIconInfo($hIcon)
            _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2], $aCursor[4] - $aIcon[3], $hIcon)
        EndIf
    EndIf

    _WinAPI_ReleaseDC($hWnd, $hDDC)
    _WinAPI_DeleteDC($hCDC)
    If $sFileName = "" Then Return $hBMP

    _ScreenCapture_SaveImage($sFileName, $hBMP)
EndFunc

If you look carfully, I have taken a shortcut at some point (cf. '$WINDOW_BORDER_WIDTH_OLD_STYLE') so I cannot guarantee full functionality on systems not using the "Classic Windows Theme".

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks for sharing!

I recommend jennico's _Borders.au3 UDF for those, who don't want to use constant border size, or _WinAPI_GetSystemMetrics.

Edited by Izebize

Share this post


Link to post
Share on other sites

Sombody brought to my attention that I forgot to mention what other files did I include. One thing leading to another I just did some more fixes on the lovely function of mine.

#include-once
#include <WinAPI.au3>
#include <ScreenCapture.au3>


; #FUNCTION# ====================================================================================================================
; Name...........: _ScreenCapture_CaptureWndV2
; Description ...: Captures a screen shot of a specified window. This function is an alternative to '_ScreenCapture_CaptureWnd'.
;                  It is able to take screenshots of layered windows (drawn by the graphic card). See 'remarks' below.
; Syntax.........: _ScreenCapture_CaptureWndV2($sFileName, $hWnd[, $iLeft = 0[, $iTop = 0[, $iRight = -1[, $iBottom = -1[, $fCursor = True]]]]])
; Parameters ....: $sFileName   - Full path and extension of the image file
;                  $hWnd        - Handle to the window to be captured
;                  $iLeft       - X coordinate of the upper left corner of the client rectangle
;                  $iTop        - Y coordinate of the upper left corner of the client rectangle
;                  $iRight      - X coordinate of the lower right corner of the rectangle
;                  $iBottom     - Y coordinate of the lower right corner of the rectangle
;                  $fCursor     - If True the cursor will be captured with the image
; Return values .: See remarks
; Author ........: Patryk Szczepankiewicz (pszczepa at gmail dot com)
; Modified.......:
; History .......: JAN 21, 2009 - Created
;                  OCT 18, 2010 - First release on the AutoIT forum
;                  OCT 28, 2010 - Cleaned the border code and fixed the capture of the cursor.
; Remarks .......: 1/ If FileName is not blank this function will capture the screen and save it to file. If FileName is blank, this
;                  function will capture the screen and return a HBITMAP handle to the bitmap image.  In this case, after you are
;                  finished with the bitmap you must call _WinAPI_DeleteObject to delete the bitmap handle.  All coordinates are  in
;                  client coordinate mode.
;
;                  2.1/ Layered windows do not appear on screenshots taken by '_ScreenCapture_Capture' because it uses the desktop's
;                  handle whereas the layered windows are drawn directly by the graphic card. 2.2/ '_ScreenCapture_CaptureWnd'
;                  is a wrapper of '_ScreenCapture_Capture' and, therefore, has the same limitations. 2.3/ Instead,
;                  '_ScreenCapture_CaptureWndV2', THIS FUNCTION, is using the handle of the targetted window to perfom its task
;                  (in a similar way than '_ScreenCapture_Capture'uses the Desktop's handle).
;
; Modified.......:
; Related .......: _WinAPI_DeleteObject
; Link ..........; http://www.autoitscript.com/forum/index.php?showtopic=65008
; Example .......; No
; Credits .......: Based on Paul Campbell's '_ScreenCapture_Capture' function and inspired by Jennico's '_WinGetBorderSize'.
; ===============================================================================================================================
Func _ScreenCapture_CaptureWndV2($sFileName, $hWnd, $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)

    Local $tRect
    Local $iWndX, $iWndY, $iWndW, $iWndH

    Local $tClient
    Local $iBorderV, $iBorderT
    Local $iPicHeight, $iPicWidth
    Local $iPicCursorX, $iPicCursorY


    Local $hDDC, $hCDC, $hBMP, $aCursor, $aIcon, $hIcon

    ; Get the absolute coordinates of the window
    $tRect = _WinAPI_GetWindowRect($hWnd)

    ; Get useful variables
    $iWndX = DllStructGetData($tRect, "Left")
    $iWndY = DllStructGetData($tRect, "Top")
    $iWndW = DllStructGetData($tRect, "Right")
    $iWndH = DllStructGetData($tRect, "Bottom")

    ; Assign automatic values: the right and bottom are computed as
    ; the width and height of the absolute coordinates of the window.
    If $iRight = -1 Then $iRight = $iWndW - $iWndX
    If $iBottom = -1 Then $iBottom = $iWndH - $iWndY

    ; Check user values: check that caller is not putting the top-left
    ; corner out of the window.
    If $iLeft > $iWndW Then $iLeft = $iWndX
    If $iTop > $iWndH Then $iTop = $iWndY

    ; Check user values: check that caller is not asking for a
    ; screenshot bigger than the window itelf.
    If $iRight > $iWndW Then $iRight = $iWndW
    If $iBottom > $iWndH Then $iBottom = $iWndH

    ; Compute the size of the final picture.
    $iPicWidth = $iRight - $iLeft
    $iPicHeight = $iBottom - $iTop

    ; Compute the borders sizes
    $tClient = _WinAPI_GetClientRect($hWnd)
    $iBorderV = (($iWndW - $iWndX) - DllStructGetData($tClient, "Right")) / 2
    $iBorderT = ($iWndH - $iWndY) - DllStructGetData($tClient, "Bottom") - $iBorderV

    ; Transfert color data
    $hDDC = _WinAPI_GetDC($hWnd)
    $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
    $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iPicWidth, $iPicHeight)
    _WinAPI_SelectObject($hCDC, $hBMP)
    _WinAPI_BitBlt($hCDC, 0, 0, $iPicWidth, $iPicHeight, $hDDC, $iLeft-$iBorderV, $iTop-$iBorderT, $SRCCOPY)

    ; Add the cursor on the screenshot
    If $fCursor Then
        $aCursor = _WinAPI_GetCursorInfo()
        If $aCursor[1] Then
            $hIcon = _WinAPI_CopyIcon($aCursor[2])
            $aIcon = _WinAPI_GetIconInfo($hIcon)
            $iPicCursorX = $aCursor[3] - $aIcon[2] - $iWndX - $iLeft
            $iPicCursorY = $aCursor[4] - $aIcon[3] - $iWndY - $iTop
            _WinAPI_DrawIcon($hCDC, $iPicCursorX, $iPicCursorY, $hIcon)
        EndIf
    EndIf

    ; Clean and save data
    _WinAPI_ReleaseDC($hWnd, $hDDC)
    _WinAPI_DeleteDC($hCDC)
    If $sFileName = "" Then Return $hBMP
    _ScreenCapture_SaveImage($sFileName, $hBMP)

EndFunc

You can test it with the following snippet:

Local $file = @DesktopDir&"\tmp.png"
Local $title = "Untitled - Notepad"
_ScreenCapture_CaptureWndV2($file, WinGetHandle($title), 10, 10, 50, 50, 0)
Run('mspaint "'&$file&'"')

I checked most cases. There was a bug with the cursor: it was not drawn at the right location. I also cleaned up the code so it's nice and neat now. All good ;)

OK, take care fellas.

P.

ScreenCaptureV2.au3

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Updating file.

#include <WindowsConstants.au3> ; ADDED FOR AUTOIT 6.3.6.1 UPGRADE

ScreenCaptureV2-v3.3.6.1.au3

Edited by Patryk

Share this post


Link to post
Share on other sites

Update for

_ScreenCapture_CaptureV2

_ScreenCapture_CaptureWndV2

Added optional parameter

$iBitBltFlag - Flag to pass to the _WinAPI_BitBlt operation

default it BitOR($SRCCOPY, $CAPTUREBLT) instead of $SRCCOPY only

Tested with AutoIT 3.3.6.1

ScreenCaptureV2.au3

Share this post


Link to post
Share on other sites

@Pinault

thanks for sharing it!

i have used it in my project and work great!

thanks again. :ILA2:


Thanksgiving...

Share this post


Link to post
Share on other sites

Hello, I've got a Problem with big Screen Resolutions.

I was'nt able to take a Screenshot with 1680 x 1050, the last posible Resolution was 1680 x 885. See my Code line.

_ScreenCapture_CaptureV2("c:\daten\sc\test2.jpg", 0, 0, 1680, 885, true, default)

I also tested some other values "@Desktopheight" or "@Desktopwith" but noting works, can anyone help me? I've the last Autoit Release installed.

Share this post


Link to post
Share on other sites

I guess your screenshot is excluding the taskbar? Why not use the standard UDF functions?

#include <ScreenCapture.au3>
_ScreenCapture_Capture(@ScriptDir & "\test.jpg")
_ScreenCapture_Capture(@ScriptDir & "\test.png") ; << I recommend PNG, as JPG has a know compression issue (better GDI has)

Share this post


Link to post
Share on other sites

Hi KaFu,

thank you for your post, but when I use the UDF also nothing happened. No Screenshot was taken, or no Picture was saved.

Only when I re-use values​​, then it makes a screen shot, and only up to 1650 x 885. If I use 1650 x 886 no Picture was taken.

It's even possible to make one with 3360 x 442 but no higher.

What is the Problem, or is it a bug in Autoit UDF?

webpower :-)

Share this post


Link to post
Share on other sites

This is how the function determines the size of your screen, what does this little script report?

#include <winapi.au3>
ConsoleWrite(_WinAPI_GetSystemMetrics(0) & @crlf) ; $__SCREENCAPTURECONSTANT_SM_CXSCREEN
ConsoleWrite(_WinAPI_GetSystemMetrics(1) & @crlf) ; $__SCREENCAPTURECONSTANT_SM_CXSCREEN

Share this post


Link to post
Share on other sites

It reports 1680 1050.

Share this post


Link to post
Share on other sites

Already found a bug in the original _ScreenCapture_Capture() function :lol:, will report it... Here we go step by step:

#include <ScreenCapture.au3>
Local $iRet = _ScreenCapture_Capture_Ex(@ScriptDir & "\test.png")
ConsoleWrite(@error & @tab & @extended & @tab & $iRet & @crlf)
Local $iFileExists = FileExists(@ScriptDir & "\test.png")
ConsoleWrite("Fileexists: " & $iFileExists & @CRLF)
If $iFileExists Then
 _GDIPlus_Startup()
 $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test.png")
 ConsoleWrite(_GDIPlus_ImageGetWidth($hImage) & "x" & _GDIPlus_ImageGetHeight($hImage) & @CRLF)
 _GDIPlus_ImageDispose($hImage)
 _GDIPlus_Shutdown()
EndIf
Func _ScreenCapture_Capture_Ex($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
 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 ; Bug !!!
 Local $iH = ($iBottom - $iTop) ; + 1 ; Bug !!!
 ConsoleWrite($iW & "x" & $iH & @crlf)
 Local $hWnd = _WinAPI_GetDesktopWindow()
 ConsoleWrite(@error & @tab & IsHWnd($hWnd) & @crlf)
 Local $hDDC = _WinAPI_GetDC($hWnd)
 ConsoleWrite(@error & @crlf)
 Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
 ConsoleWrite(@error & @crlf)
 Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH)
 ConsoleWrite(@error & @tab & IsPtr($hBMP) & @crlf)
 _WinAPI_SelectObject($hCDC, $hBMP)
 _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY)
 If $fCursor Then
  Local $aCursor = _WinAPI_GetCursorInfo()
  If $aCursor[1] Then
   Local $hIcon = _WinAPI_CopyIcon($aCursor[2])
   Local $aIcon = _WinAPI_GetIconInfo($hIcon)
   _WinAPI_DeleteObject($aIcon[4]) ; delete bitmap mask return by _WinAPI_GetIconInfo()
   If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo()
   _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
   _WinAPI_DestroyIcon($hIcon)
  EndIf
 EndIf
 _WinAPI_ReleaseDC($hWnd, $hDDC)
 _WinAPI_DeleteDC($hCDC)
 ConsoleWrite("$sFileName: " & $sFileName & @crlf)
 If $sFileName = "" Then Return $hBMP
 Local $ret = _ScreenCapture_SaveImage($sFileName, $hBMP, True)
 Return SetError(@error, @extended, $ret)
EndFunc   ;==>_ScreenCapture_Capture_Ex

Share this post


Link to post
Share on other sites

WOW!! Thank you, I tested it on my WinXP PC and it does'nt work - no screenshot was taken. but on my Win7 Machine the screenshot was taken!! That is curious!!,now I'm a little confused..

The Console Output on XP:

1680x1050
0 1
0
0
0 1
$sFileName: C:\daten\autoit_dev\test.png
1 0 False
Fileexists: 0

On Win 7

1680x1050
0 1
0
0
0 1
$sFileName: C:\daten\autoit_dev\test.png
0 0 True
Fileexists: 1
1680x1050

Share this post


Link to post
Share on other sites

And what does this do on your XP machine?

#include <ScreenCapture.au3>
_ScreenCapture(@ScriptDir & "\test.png")
_ScreenCapture(@ScriptDir & "\test.bmp")
_ScreenCapture(@ScriptDir & "\test.jpg")
_ScreenCapture(@ScriptDir & "\test.tif")
Func _ScreenCapture($sFileName)
 Local $iRet = _ScreenCapture_Capture_Ex($sFileName)
 ConsoleWrite(@error & @TAB & @extended & @TAB & $iRet & @CRLF)
 Local $iFileExists = FileExists($sFileName)
 ConsoleWrite("Fileexists: " & $iFileExists & @CRLF)
 If $iFileExists Then
  _GDIPlus_Startup()
  $hImage = _GDIPlus_ImageLoadFromFile($sFileName)
  ConsoleWrite(_GDIPlus_ImageGetWidth($hImage) & "x" & _GDIPlus_ImageGetHeight($hImage) & @CRLF)
  _GDIPlus_ImageDispose($hImage)
  _GDIPlus_Shutdown()
 EndIf
EndFunc   ;==>_ScreenCapture
Func _ScreenCapture_Capture_Ex($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $fCursor = True)
 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 ; Bug !!!
 Local $iH = ($iBottom - $iTop) ; + 1 ; Bug !!!
 ConsoleWrite($iW & "x" & $iH & @CRLF)
 Local $hWnd = _WinAPI_GetDesktopWindow()
 ConsoleWrite(@error & @TAB & IsHWnd($hWnd) & @CRLF)
 Local $hDDC = _WinAPI_GetDC($hWnd)
 ConsoleWrite(@error & @CRLF)
 Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
 ConsoleWrite(@error & @CRLF)
 Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH)
 ConsoleWrite(@error & @TAB & IsPtr($hBMP) & @CRLF)
 ConsoleWrite(_WinAPI_SelectObject($hCDC, $hBMP) & @CRLF)
 ConsoleWrite(_WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY) & @CRLF)
 If $fCursor Then
  Local $aCursor = _WinAPI_GetCursorInfo()
  If $aCursor[1] Then
   Local $hIcon = _WinAPI_CopyIcon($aCursor[2])
   Local $aIcon = _WinAPI_GetIconInfo($hIcon)
   _WinAPI_DeleteObject($aIcon[4]) ; delete bitmap mask return by _WinAPI_GetIconInfo()
   If $aIcon[5] <> 0 Then _WinAPI_DeleteObject($aIcon[5]); delete bitmap hbmColor return by _WinAPI_GetIconInfo()
   _WinAPI_DrawIcon($hCDC, $aCursor[3] - $aIcon[2] - $iLeft, $aCursor[4] - $aIcon[3] - $iTop, $hIcon)
   _WinAPI_DestroyIcon($hIcon)
  EndIf
 EndIf
 _WinAPI_ReleaseDC($hWnd, $hDDC)
 _WinAPI_DeleteDC($hCDC)
 ConsoleWrite("$sFileName: " & $sFileName & @CRLF)
 If $sFileName = "" Then Return $hBMP
 Local $ret = _ScreenCapture_SaveImage($sFileName, $hBMP, True)
 Return SetError(@error, @extended, $ret)
EndFunc   ;==>_ScreenCapture_Capture_Ex

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