KaFu Posted May 3, 2019 Posted May 3, 2019 expandcollapse popup#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() argumentum 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
argumentum Posted May 3, 2019 Posted May 3, 2019 (edited) ..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 May 3, 2019 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now