Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WinAPI.au3>
- #include <Gdiplus.au3>
- #include <WindowsConstants.au3>
- Run("mspaint.exe")
- Sleep(1000) ; wait for paint
- $hwnd = WinGetHandle("Untitled - Paint")
- If @error then Exit
- WinMove($hwnd, "", 100, 100, 800, 600)
- $hDC = _WinAPI_GetDC($hwnd) ; screen
- $pWin = WinGetPos($hwnd)
- $gui = GUICreate("", $pWin[2], $pWin[3])
- GUISetState()
- _GDIPlus_Startup()
- $graphic = _GDIPlus_GraphicsCreateFromHWND($gui)
- While 1
- $time = TimerInit()
- $bitmap = ScreenToBitmap($hDC, $pWin[2], $pWin[3])
- $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($bitmap)
- _GDIPlus_GraphicsDrawImage($graphic, $hBitmap, 0, 0)
- _WinAPI_DeleteObject($bitmap)
- _GDIPlus_BitmapDispose($hBitmap)
- $timediff = TimerDiff($time)
- ConsoleWrite("FPS: " & Round(1000 / $timediff) & " took: " & $timediff & @CRLF)
- If GUIGetMsg() = - 3 Or WinExists($hwnd) = False Then
- WinKill($hwnd)
- Exit
- EndIf
- WEnd
- Func ScreenToBitmap($hDC, $iWidth, $iHeight)
- Local $tDC = _WinAPI_CreateCompatibleDC($hDC)
- Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
- _WinAPI_SelectObject($tDC, $hBMP)
- _WinAPI_BitBlt($tDC, 0, 0, $iWidth, $iHeight, $hDC, 0, 0, $SRCCOPY)
- _WinAPI_DeleteDC($tDC)
- Return $hBMP
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement