milos83 Posted February 16, 2018 Posted February 16, 2018 (edited) If I set the transparency with WinSetTrans, screenshot can't be made. This is Windows 7 related. Win 10 works fine Run the attached file #include <ScreenCapture.au3> ;GUI1 $gui1 = GUICreate("gui1", 200, 200, 200, 200) GUICtrlCreateLabel("GUI 1 LABEL", 50, 50 ) GUISetState() ;GUI 2 with transparency is completely ignored by _ScreenCapture_Capture $gui2 = GUICreate("gui1", 200, 200, 200, 200, -1, -1, $gui1) GUICtrlCreateLabel("GUI 2 LABEL", 100, 100 ) GUISetState() WinSetTrans($gui2, "", 150) Sleep(2000) _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image1.jpg", 200, 200, 405, 410) ShellExecute(@MyDocumentsDir & "\GDIPlus_Image1.jpg") As you can see, the semi transparent window will not be visible in the screenshot. I noticed that a couple of screen recording tools are acting the same. (But there are those that do work) I tried different ways on getting the screenshot and none worked. Printscreen does work. Is there a way to solve this without using Printscreen? ScreenCaptureProblem.au3 Edited February 16, 2018 by milos83
InnI Posted February 16, 2018 Posted February 16, 2018 1 hour ago, milos83 said: This is Windows 7 related. It seems like you use basic windows theme without aero. If so then choose some aero theme and try again.
milos83 Posted February 16, 2018 Author Posted February 16, 2018 5 hours ago, InnI said: It seems like you use basic windows theme without aero. If so then choose some aero theme and try again. You are right! Any way to fix it without turning Aero theme on?
InnI Posted February 18, 2018 Posted February 18, 2018 On 16.02.2018 at 8:20 PM, milos83 said: Any way to fix it without turning Aero theme on? Try to change _ScreenCapture_Capture: add $CAPTUREBLT from WindowsConstants.au3 to _WinAPI_BitBlt _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, BitOR($__SCREENCAPTURECONSTANT_SRCCOPY, $CAPTUREBLT))
milos83 Posted February 23, 2018 Author Posted February 23, 2018 (edited) On 2/18/2018 at 10:10 AM, InnI said: Try to change _ScreenCapture_Capture: add $CAPTUREBLT from WindowsConstants.au3 to _WinAPI_BitBlt _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, BitOR($__SCREENCAPTURECONSTANT_SRCCOPY, $CAPTUREBLT)) That does the trick! Since I don't know if there are any side effects I am using this alternative only if WIN7+AeroOFF. expandcollapse popupFunc _ScreenCapture_Capture2($sFileName = "", $iLeft = 0, $iTop = 0, $iRight = -1, $iBottom = -1, $bCursor = True) Local $bRet = False If $iRight = -1 Then $iRight = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CXSCREEN) - 1 If $iBottom = -1 Then $iBottom = _WinAPI_GetSystemMetrics($__SCREENCAPTURECONSTANT_SM_CYSCREEN) - 1 If $iRight < $iLeft Then Return SetError(-1, 0, $bRet) If $iBottom < $iTop Then Return SetError(-2, 0, $bRet) Local $iW = ($iRight - $iLeft) + 1 Local $iH = ($iBottom - $iTop) + 1 Local $hWnd = _WinAPI_GetDesktopWindow() Local $hDDC = _WinAPI_GetDC($hWnd) Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iW, $iH) _WinAPI_SelectObject($hCDC, $hBMP) ;~ _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, $__SCREENCAPTURECONSTANT_SRCCOPY) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $hDDC, $iLeft, $iTop, BitOR($__SCREENCAPTURECONSTANT_SRCCOPY, $CAPTUREBLT)) If $bCursor Then Local $aCursor = _WinAPI_GetCursorInfo() If Not @error And $aCursor[1] Then $bCursor = True ; Cursor info was found. Local $hIcon = _WinAPI_CopyIcon($aCursor[2]) Local $aIcon = _WinAPI_GetIconInfo($hIcon) If Not @error Then _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) EndIf _WinAPI_DestroyIcon($hIcon) EndIf EndIf _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) If $sFileName = "" Then Return $hBMP $bRet = _ScreenCapture_SaveImage($sFileName, $hBMP, True) Return SetError(@error, @extended, $bRet) EndFunc ;==>_ScreenCapture_Capture Thank you @InnI Edited February 23, 2018 by milos83
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