|
本帖最后由 z761003 于 2022-9-28 22:25 编辑
论坛里搜了个后台截图的函数,可以截,可截图必须是从窗口左上角坐标 x=0 y=0开始截,想把它改成截取指定区域改不来,请教下获取了位图对象句柄 $hBitmap 如果截取其中的部分呢(指定坐标区域)
是不是使用_GDIPlus_BitmapCloneArea(),搞半天也没搞出来,希望谁能帮改下
Func _ScreenHideWindow($i_win_handle, $iW, $iH)
Local $aRet = DllCall($dll, "hwnd", "GetWindowDC", "hwnd", $i_win_handle)
If @error Then Return SetError(@error, 0, -1)
Local $hDC = $aRet[0]
$aRet = DllCall($hDLLGDI32, "hwnd", "CreateCompatibleDC", "hwnd", $hDC)
If @error Then Return SetError(@error, 0, -1)
Local $hMemDC = $aRet[0]
$aRet = DllCall($hDLLGDI32, "hwnd", "CreateCompatibleBitmap", "hwnd", $hDC, "int", $iW, "int", $iH)
If @error Then Return SetError(@error, 0, -1)
Local $hBitmap = $aRet[0]
;想把截取 $hBitmap 指定区域
$aRet = DllCall($hDLLGDI32, "hwnd", "SelectObject", "hwnd", $hMemDC, "hwnd", $hBitmap)
If @error Then Return SetError(@error, 0, -1)
Local $hOld = $aRet[0]
$aRet = DllCall($dll, "int", "ReleaseDC", "hwnd", $i_win_handle, "hwnd", $hDC)
If @error Then Return SetError(@error, 0, -1)
_PrintWindow($i_win_handle, $hMemDC)
$aRet = DllCall($hDLLGDI32, "hwnd", "SelectObject", "hwnd", $hMemDC, "hwnd", $hOld)
If @error Then Return SetError(@error, 0, -1)
$aRet = DllCall($hDLLGDI32, "int", "DeleteDC", "hwnd", $hMemDC)
If @error Then Return SetError(@error, 0, -1)
$aRet = DllCall($hDLLGDI32, "int", "DeleteObject", "int", $hBitmap)
If @error Then Return SetError(@error, 0, -1)
Return
EndFunc
Func _PrintWindow($hWnd, $hMemDC, $iFlag = 0)
Local $aRet = DllCall($dll, "int", "PrintWindow", _
"hwnd", $hWnd, _
"hwnd", $hMemDC, _
"int", $iFlag)
Return $aRet[0]
EndFunc ;==>_PrintWindow
|
|