Jump to content

Recommended Posts

JRSmile

Hi Folks,

i was looking for a fast an reliable way to make screenshots and came across this: https://github.com/pgurenko/DXGICaptureSample

https://msdn.microsoft.com/en-us/library/windows/desktop/bb205075(v=vs.85).aspx

so far i managed to find the following code on the forum but not more.

;~ #AutoIt3Wrapper_UseX64=y
#include <WinAPI.au3>
Global Const $DXGI_ERROR_NOT_FOUND = 0x887A0002
Global Const $sTag_DummyIDXGIObject = "Dummy1 hresult();Dummy2 hresult();Dummy3 hresult();Dummy4 hresult();"
Global Const $sTag_IDXGIFactory = $sTag_DummyIDXGIObject & "EnumAdapters hresult(uint;ptr*); MakeWindowAssociation hresult(hwnd;uint); GetWindowAssociation hresult(hwnd*); CreateSwapChain hresult(ptr;ptr;ptr*); CreateSoftwareAdapter hresult(hwnd;ptr*);"
Global Const $sIID_IDXGIFactory = "{7b7166ec-21c7-44ae-b21a-c9ae321ae369}"

Global Const $sTag__IDXGIAdapter = $sTag_DummyIDXGIObject & "EnumOutputs hresult(uint;ptr*);GetDesc hresult(ptr);CheckInterfaceSupport hresult(ptr;long)"
Global Const $sIID_IDXGIAdapter = "{2411e7e1-12ac-4ccf-bd14-9798e8534dc0}"
Global Const $sTag_DXGI_ADAPTER_DESC = "wchar Description[128];uint VendorId;uint DeviceId;uint SubSysId;uint Revision;ULONG_PTR DedicatedVideoMemory;ULONG_PTR DedicatedSystemMemory;ULONG_PTR SharedSystemMemory;DWORD LowPart;LONG HighPart;"


DllOpen("DXGI.dll")

Local $tRIID_IDXGIFactory = _WinAPI_CLSIDFromString($sIID_IDXGIFactory)
Local $aRet = DllCall("DXGI.dll", "long", "CreateDXGIFactory1", "ptr", DllStructGetPtr($tRIID_IDXGIFactory), "ptr*", 0)
If @error Or UBound($aRet) <> 3 Then
    $aRet = DllCall("DXGI.dll", "long", "CreateDXGIFactory", "ptr", DllStructGetPtr($tRIID_IDXGIFactory), "ptr*", 0)
    If @error Or UBound($aRet) <> 3 Then
        Exit ConsoleWrite("Unable to get IDXGIFactory Interface Pointer" & @CRLF)
    EndIf
EndIf

Local $pIDXGIFactory = $aRet[2]
ConsoleWrite("$pIDXGIFactory: " & $pIDXGIFactory & @CRLF)
If Not $pIDXGIFactory Then Exit ConsoleWrite("Unable to get IDXGIFactory Interface Pointer" & @CRLF)
Local $oDXGIFactory = ObjCreateInterface($pIDXGIFactory, $sIID_IDXGIFactory, $sTag_IDXGIFactory)
ConsoleWrite("IsObj($oDXGIFactory): " & IsObj($oDXGIFactory) & @CRLF)
Local $pAdapter = 0
Local $oAdapter = 0
Local $i = 0
Local $tApdaterDescription = 0
While Not $oDXGIFactory.EnumAdapters($i, $pAdapter) = $DXGI_ERROR_NOT_FOUND
    ConsoleWrite("$pAdapter: " & $pAdapter & @CRLF)
    $oAdapter = ObjCreateInterface($pAdapter, $sIID_IDXGIAdapter, $sTag__IDXGIAdapter)
    ConsoleWrite("IsObj($oAdapter): " & IsObj($oAdapter) & @CRLF)
    If IsObj($oAdapter) Then
        $tApdaterDescription = DllStructCreate($sTag_DXGI_ADAPTER_DESC)
        $oAdapter.GetDesc(DllStructGetPtr($tApdaterDescription))
        ConsoleWrite(">>>>>>>>>>>Adapter Information<<<<<<<<<<<<<" & @CRLF)
        ConsoleWrite("Description: " & $tApdaterDescription.Description & @CRLF)
        ConsoleWrite("VendorId: " & $tApdaterDescription.VendorId & @CRLF)
        ConsoleWrite("DeviceId: " & $tApdaterDescription.DeviceId & @CRLF)
        ConsoleWrite("SubSysId: " & $tApdaterDescription.SubSysId & @CRLF)
        ConsoleWrite("Revision: " & $tApdaterDescription.Revision & @CRLF)
        ConsoleWrite("DedicatedVideoMemory: " & $tApdaterDescription.DedicatedVideoMemory & @CRLF)
        ConsoleWrite("DedicatedSystemMemory: " & $tApdaterDescription.DedicatedSystemMemory & @CRLF)
        ConsoleWrite("SharedSystemMemory: " & $tApdaterDescription.SharedSystemMemory & @CRLF)
        ConsoleWrite(@CRLF & @CRLF)
        $oAdapter = 0
    EndIf
    $i += 1
WEnd

Func _WinAPI_CLSIDFromString($sGUID)
    Local $tGUID = DllStructCreate('ulong Data1;ushort Data2;ushort Data3;byte Data4[8]')
    Local $iRet = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $sGUID, 'ptr', DllStructGetPtr($tGUID))
    If (@error) Or ($iRet[0]) Then
        Return SetError(@error, @extended, 0)
    EndIf
    Return $tGUID
EndFunc   ;==>_WinAPI_CLSIDFromString

my question is how would i go from c to autoit. and make it reliable.

the most interresting function is DXGIOutputDuplication::AcquireNextFrame

i wonder if it is possible to request regions of a screen and if it is possible to get hex values of the pixels very fast.

Edited by JRSmile

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites
Danyfirex

I think is possible. I think this C++ Example can help you.

 

 

Saludos

Share this post


Link to post
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

×