) for the raster operation code with BitBlt, which is $CAPTUREBLT (which is exactly what i needed).
But the thing is: you also can use it directly with StretchBlt since it has the same $iROP parameter.
But then i noticed that the zoom window is being visible again in the zoomed view, which is kind of one step further, one step back.
Then i thought it must be possible to take a bitmap of the original Desktop (without layered windows) and additionally merge in the bitmap of the layered rectangle window.
#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
; Modified from http://www.autoitscript.com/forum/index....=&showtopic=97126&view=findpos
;~ Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
Local $f = 0, $GDIdll = DllOpen("gdi32.dll")
Local $hBitmap, $hGui, $hGraphic, $hImage2, $GuiSizeX = @DesktopWidth, $GuiSizeY = @DesktopHeight
Local $GuiSize = 70, $hWnd, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
Local $iX1 = 0, $iY1 = 0, $tPoint, $pPoint, $hBMPBuff, $hGraphicGUI, $hPen, $aMPosNew
Local $iOpacity = 255, $dll = DllOpen("user32.dll")
Local $aMPos = -1
$hGui = GUICreate("L1", $GuiSizeX, $GuiSizeY, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST + $WS_EX_TRANSPARENT))
GUISetState()
$ZoomSizeX = 256
$ZoomSizeY = 256
$ZoomGUI = GUICreate("Zoom", $ZoomSizeX, $ZoomSizeY, 400, 200, BitOR($WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_BORDER, $WS_CAPTION), $WS_EX_TOPMOST)
WinSetTrans($ZoomGUI, "", 255); I dont know why but this excludes the ZoomGUI from being drawn with StretchBlt, neat!
GUISetBkColor(0xEEEEEE)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitF")
GUISetState()
_GDIPlus_Startup()
$hWnd = _WinAPI_GetDC(0)
$L1hDC = _WinAPI_CreateCompatibleDC($hWnd)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd, $GuiSizeX, $GuiSizeY)
_WinAPI_SelectObject($L1hDC, $hBitmap)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($L1hDC)
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphic)
$hGraphicGUI = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)
_GDIPlus_GraphicsClear($hGraphic); Add ,0x01000000) to disable underling desktop
$hPen = _GDIPlus_PenCreate(0xffff0000, 10)
;~ $hBrush = _GDIPlus_BrushCreateSolid(0xffff0000)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $GuiSizeX);$iWidth )
DllStructSetData($tSize, "Y", $GuiSizeY);$iHeight)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT); Create point destination structure here
$pPoint = DllStructGetPtr($tPoint); Create pointer to this dll data structure, $pPTDest parameter
DllStructSetData($tPoint, "X", $iX1)
DllStructSetData($tPoint, "Y", $iY1)
_WinAPI_UpdateLayeredWindow($hGui, $hWnd, $pPoint, $pSize, $L1hDC, $pSource, 0, $pBlend, $ULW_ALPHA)
$ZoomDC = _WinAPI_GetDC($ZoomGUI)
Global $DeskDC = _WinAPI_GetDC(0)
Do
Select
Case _IsPressed("11", $dll); Ctrl to start drag rect
Do
$aMPosNew = MouseGetPos()
If $aMPos = -1 Then ; Drag Start
$aMPos = $aMPosNew
EndIf
_GDIPlus_GraphicsClear($hGraphic)
; I used _Iif() from Misc.au3 instead using of _Min() from Math.au3.
$RectStartX = _Iif($aMPos[0] < $aMPosNew[0], $aMPos[0], $aMPosNew[0])
$RectStartY = _Iif($aMPos[1] < $aMPosNew[1], $aMPos[1], $aMPosNew[1])
_GDIPlus_GraphicsDrawRect($hGraphic, $RectStartX, $RectStartY, Abs($aMPosNew[0] - $aMPos[0]), Abs($aMPosNew[1] - $aMPos[1]), $hPen)
_WinAPI
_StretchBltNOTLayCombine
($ZoomDC, 0, 0, $ZoomSizeX, $ZoomSizeY, $DeskDC, $aMPosNew[0] - 64, $aMPosNew[1] - 64, 256 / 2, 256 / 2, $SRCCOPY, $L1hDC) ; 256/2 = Double Zoom
;~ _WinAPI_StretchBlt($ZoomDC, 0, 0, $ZoomSizeX, $ZoomSizeY, $DeskDC, $aMPosNew[0]-64, $aMPosNew[1]-64, 256 / 2, 256 / 2, $SRCCOPY) ; less CPU
_WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $L1hDC, $pSource, 0, $pBlend, $ULW_ALPHA)
Sleep(10)
Until Not _IsPressed("11", $dll)
$aMPos = -1 ; Drag End
Case _IsPressed("04", $dll) Or _IsPressed("11", $dll) ; Middle mouse button 0r Ctrl key <======= Clear screen of rectangles.
_GDIPlus_GraphicsClear($hGraphic)
_WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $L1hDC, $pSource, 0, $pBlend, $ULW_ALPHA)
Case Else
$aMPosNew = MouseGetPos()
_WinAPI
_StretchBltNOTLayCombine
($ZoomDC, 0, 0, $ZoomSizeX, $ZoomSizeY, $DeskDC, $aMPosNew[0] - 64, $aMPosNew[1] - 64, 256 / 2, 256 / 2, $SRCCOPY, $L1hDC) ; 256/2 = Double Zoom
;~ _WinAPI_StretchBlt($ZoomDC, 0, 0, $ZoomSizeX, $ZoomSizeY, $DeskDC, $aMPosNew[0]-64, $aMPosNew[1]-64, 256 / 2, 256 / 2, $SRCCOPY) ; less CPU
EndSelect
Sleep(10)
Until $f
_WinAPI_ReleaseDC(0, $DeskDC)
_WinAPI_ReleaseDC($ZoomGUI, $ZoomDC)
DllClose($dll)
DllClose($GDIdll)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphicGUI)
_GDIPlus_GraphicsDispose($hGraphic)
_WinAPI_ReleaseDC(0, $hWnd)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($L1hDC)
_GDIPlus_Shutdown()
Func _WinAPI
_StretchBltNOTLayCombine
($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iROP, $hAddDC); $hAddDC = DC to a bitmap to mix in with black transparency
; create a Memory Bitmap to combine the Desktop DC(without any layered Windows) with the DC of the layered rectangle window (fullscreen)
Local $MashDC = _WinAPI_CreateCompatibleDC($DeskDC)
Local $hMashBitmap = _WinAPI_CreateCompatibleBitmap($DeskDC, @DesktopWidth, @DesktopHeight)
Local $old = _WinAPI_SelectObject($MashDC, $hMashBitmap)
; copy whole Desktop Bitmap to memory (without layered windows)
_WinAPI_BitBlt($MashDC, 0, 0, @DesktopWidth, @DesktopHeight, $DeskDC, 0, 0, $iROP)
; copy additional bitmap with black color made transparent (only red rectangles visible)
Local $aResult = DllCall($GDIdll, "int", "GdiTransparentBlt", "hwnd", $MashDC, "int", 0, "int", 0, "int", @DesktopWidth, "int", @DesktopHeight, _
"hwnd", $hAddDC, "int", 0, "int", 0, "int", @DesktopWidth, "int", @DesktopHeight, "uint", 0x000000); make black color transparent (BGR format)
; copy merged bitmap from memory to Desktop
_WinAPI
_StretchBlt
($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $MashDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iROP)
_WinAPI_DeleteObject($hMashBitmap)
_WinAPI_DeleteDC($MashDC)
If @error Then Return SetError(@error, 0, False)
Return $aResult[0] <> 0
EndFunc ;==>_WinAPI_StretchBltNOTLayCombine
Func _WinAPI
_StretchBlt
($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iROP)
;~ Local $aResult = _WinAPI_BitBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iROP)
Local $aResult = DllCall($GDIdll, "int", "StretchBlt", "hwnd", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidth, "int", $iHeight, _
"hwnd", $hSrcDC, "int", $iXSrc, "int", $iYSrc, "int", $iWidthSrc, "int", $iHeightSrc, "int", $iROP)
If @error Then Return SetError(@error, 0, False)
Return $aResult[0] <> 0
EndFunc ;==>_WinAPI_StretchBlt
Func ExitF
()
$f = 1
EndFunc ;==>ExitF
But this way is much more CPU intensive than simply use StretchBlt, is there another way to make it more slim?
. I have turned it off and therefore BitBlt will behave different.