Jump to content

dll call failed


JRSmile
 Share

Recommended Posts

#include <ScreenCapture.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup() ;initialize GDI+

$hDLL = DllOpen("DXGCap32.dll")

;~ void init()
DllCall($hDLL, "none:cdecl", "init")
If @error Then Exit -1

;~ void* create_dxgi_manager()
$aCall = DllCall($hDLL, "ptr:cdecl", "create_dxgi_manager")
If @error Then Exit -2

; Read data
$pManager = $aCall[0]

;~ void get_output_dimensions(void*const dxgi_manager, uint32_t* width, uint32_t* height)
$aCall = DllCall($hDLL, "none:cdecl", "get_output_dimensions", "ptr", $pManager, "uint*", 0, "uint*", 0)
If @error Then Exit -3

ConsoleWrite("Width = " & $aCall[2] & ", Height = " & $aCall[3] & @CRLF)
$iWidth = $aCall[2]
$iHeight = $aCall[3]

;~ uint8_t get_frame_bytes(void* dxgi_manager, size_t* o_size, uint8_t** o_bytes)
Local $pBuffer, $iBufferSize
$aCall = DllCall($hDLL, "byte:cdecl", "get_frame_bytes", "ptr", $pManager, "uint*", 0, "ptr*", 0)
If @error Then Exit -4

; Read data
$iBufferSize = $aCall[2]
$pBuffer = $aCall[3]

; Fill the buffer
$aCall = DllCall($hDLL, "byte:cdecl", "get_frame_bytes", "ptr", $pManager, "uint*", $iBufferSize, "ptr", $pBuffer)
If @error Then Exit -5

#cs
    ; Make the data accessible thru dllstruct
    $tData = DllStructCreate("byte[" & $iBufferSize & "]", $pBuffer)
    If @error Then Exit -6
#ce

ConsoleWrite($iWidth & @TAB & $iHeight & @TAB & $pBuffer & @CRLF)

Local $hBMP = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB, 4 * $iWidth, $pBuffer)
ConsoleWrite($hBMP & @CRLF)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBMP)
_GDIPlus_ImageDispose($hBMP)
ConsoleWrite($hBitmap & @CRLF)
ConsoleWrite(_ScreenCapture_SaveImage(@ScriptDir & "\test.bmp", $hBitmap) & @CRLF)
_WinAPI_DeleteObject($hBitmap)

;~ void delete_dxgi_manager(void* dxgi_manager)
DllCall($hDLL, "none:cdecl", "delete_dxgi_manager", "ptr", $pManager)
If @error Then Exit -7

_GDIPlus_Shutdown()

 

Link to comment
Share on other sites

..tho most will be using x64, so, change the top of the script with:

#AutoIt3Wrapper_UseX64=y
#include <ScreenCapture.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup() ;initialize GDI+

$hDLL = DllOpen("DXGCap64.dll")

... ...

PS: ..also, saving as .PNG makes a much smaller file :) 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...