Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WinAPI.au3>
- #include <GDIPlus.au3>
- #include <Array.au3>
- $hWnd = GUICreate("Test", 400, 400)
- $cButton1 = GUICtrlCreateButton("Test", 50, 50, 50, 25)
- $cEdit = GUICtrlCreateEdit("AutoIt rocks!!", 50, 70, 200, 200)
- GUISetState()
- Sleep(500)
- $hBMP = _ScreenCapture_CaptureWndEx($hWnd, -1, -1)
- _GDIPlus_Startup()
- $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
- _GDIPlus_ImageSaveToFile($hBitmap, @DesktopDir & "\Test.png")
- _GDIPlus_BitmapDispose($hBitmap)
- _GDIPlus_Shutdown()
- _WinAPI_DeleteObject($hBMP)
- Do
- Until GUIGetMsg() = -3
- Func _ScreenCapture_CaptureWndEx($hWnd, $iWidth = -1, $iHeight = -1)
- If $iWidth = -1 Then $iWidth = _WinAPI_GetClientWidth($hWnd)
- If $iHeight = -1 Then $iHeight = _WinAPI_GetClientHeight($hWnd)
- Local $hDDC = _WinAPI_GetDC($hWnd)
- Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC)
- Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight)
- _WinAPI_SelectObject($hCDC, $hBMP)
- _WinAPI_BitBlt($hCDC, 0, 0, $iWidth, $iHeight, $hDDC, 0, 0, 0x00CC0020)
- _WinAPI_ReleaseDC($hWnd, $hDDC)
- _WinAPI_DeleteDC($hCDC)
- Return $hBMP
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement