Advertisement
lyogadi

Handle Capture

May 6th, 2018
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.79 KB | None | 0 0
  1. Func _HandleCapture($Title, $SavePath = @ScriptDir&"\ImgCaptureByAutoIt.bmp")
  2.     ;Doing the actual window capture and saving it inside $hBMP
  3.     Local $Hwnd = WinGetHandle($Title)
  4.     Local $hDDC = _WinAPI_GetDC($hwnd)
  5.     Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
  6.     Local $Width = _WinAPI_GetWindowWidth($hwnd)
  7.     Local $Height = _WinAPI_GetWindowHeight($hwnd)
  8.     Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $Width, $Height)
  9.     _WinAPI_SelectObject($hCDC, $hBMP)
  10.     DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hwnd, "hdc", $hCDC, "int", 0)
  11.     _WinAPI_BitBlt($hCDC, 0, 0, $Width, $Height, $hDDC, 0, 0, $SRCCOPY)
  12.     _ScreenCapture_SaveImage($SavePath, $hBMP, False) ; Debug
  13.     ;delete resources
  14.     _WinAPI_ReleaseDC($hwnd, $hDDC)
  15.     _WinAPI_DeleteDC($hCDC)
  16.     Return $hBMP
  17. EndFunc   ;==>_HandleCapture
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement