Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.26 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <Gdiplus.au3>
  3. #include <WindowsConstants.au3>
  4.  
  5. Run("mspaint.exe")
  6. Sleep(1000) ; wait for paint
  7.  
  8. $hwnd = WinGetHandle("Untitled - Paint")
  9. If @error then Exit
  10.  
  11. WinMove($hwnd, "", 100, 100, 800, 600)
  12.  
  13. $hDC = _WinAPI_GetDC($hwnd) ; screen
  14. $pWin = WinGetPos($hwnd)
  15.  
  16. $gui = GUICreate("", $pWin[2], $pWin[3])
  17. GUISetState()
  18.  
  19. _GDIPlus_Startup()
  20. $graphic = _GDIPlus_GraphicsCreateFromHWND($gui)
  21.  
  22. While 1
  23.  
  24.     $time = TimerInit()
  25.     $bitmap = ScreenToBitmap($hDC, $pWin[2], $pWin[3])
  26.     $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($bitmap)
  27.  
  28.     _GDIPlus_GraphicsDrawImage($graphic, $hBitmap, 0, 0)
  29.  
  30.     _WinAPI_DeleteObject($bitmap)
  31.     _GDIPlus_BitmapDispose($hBitmap)
  32.  
  33.     $timediff =  TimerDiff($time)
  34.     ConsoleWrite("FPS: " & Round(1000 / $timediff) & "  took: " & $timediff & @CRLF)
  35.  
  36.     If GUIGetMsg() = - 3 Or WinExists($hwnd) = False Then
  37.         WinKill($hwnd)
  38.         Exit
  39.     EndIf
  40. WEnd
  41.  
  42.  
  43. Func ScreenToBitmap($hDC, $iWidth, $iHeight)
  44.  
  45.     Local $tDC = _WinAPI_CreateCompatibleDC($hDC)
  46.     Local $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
  47.     _WinAPI_SelectObject($tDC, $hBMP)
  48.     _WinAPI_BitBlt($tDC, 0, 0, $iWidth, $iHeight, $hDC, 0, 0, $SRCCOPY)
  49.  
  50.     _WinAPI_DeleteDC($tDC)
  51.     Return $hBMP
  52. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement