comradeb14ck Posted February 24, 2008 Share Posted February 24, 2008 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! Link to comment Share on other sites More sharing options...
Zedna Posted February 24, 2008 Share Posted February 24, 2008 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 ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
comradeb14ck Posted February 24, 2008 Author Share Posted February 24, 2008 Thanks. I don't need help. I just wanted to ask the author a question. Link to comment Share on other sites More sharing options...
Zedna Posted February 24, 2008 Share Posted February 24, 2008 Thanks. I don't need help. I just wanted to ask the author a question.So ask question here Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
numdig Posted January 28, 2009 Share Posted January 28, 2009 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? Link to comment Share on other sites More sharing options...
Zedna Posted January 28, 2009 Share Posted January 28, 2009 (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=62035Send prepared function by PM to Gary. Edited January 28, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
numdig Posted October 18, 2010 Share Posted October 18, 2010 I have been using it for over a year now and it works fine, so here it is: expandcollapse popup; #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". Link to comment Share on other sites More sharing options...
Izebize Posted October 19, 2010 Share Posted October 19, 2010 (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 October 19, 2010 by Izebize Link to comment Share on other sites More sharing options...
numdig Posted October 29, 2010 Share Posted October 29, 2010 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. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
numdig Posted April 6, 2011 Share Posted April 6, 2011 (edited) Updating file. #include <WindowsConstants.au3> ; ADDED FOR AUTOIT 6.3.6.1 UPGRADEScreenCaptureV2-v3.3.6.1.au3 Edited April 6, 2011 by Patryk Link to comment Share on other sites More sharing options...
numdig Posted November 3, 2011 Share Posted November 3, 2011 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.1ScreenCaptureV2.au3 yutijang 1 Link to comment Share on other sites More sharing options...
yahaosoft Posted December 18, 2012 Share Posted December 18, 2012 @Pinault thanks for sharing it! i have used it in my project and work great! thanks again. Thanksgiving... Link to comment Share on other sites More sharing options...
webpower Posted January 16, 2013 Share Posted January 16, 2013 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. Link to comment Share on other sites More sharing options...
KaFu Posted January 16, 2013 Share Posted January 16, 2013 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) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
webpower Posted January 17, 2013 Share Posted January 17, 2013 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 :-) Link to comment Share on other sites More sharing options...
KaFu Posted January 17, 2013 Share Posted January 17, 2013 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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
webpower Posted January 17, 2013 Share Posted January 17, 2013 It reports 1680 1050. Link to comment Share on other sites More sharing options...
KaFu Posted January 17, 2013 Share Posted January 17, 2013 Already found a bug in the original _ScreenCapture_Capture() function , will report it... Here we go step by step: expandcollapse popup#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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
webpower Posted January 17, 2013 Share Posted January 17, 2013 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 Link to comment Share on other sites More sharing options...
KaFu Posted January 17, 2013 Share Posted January 17, 2013 And what does this do on your XP machine? expandcollapse popup#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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now