Jump to content

DXGI Screen Capture


Recommended Posts

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:-)
Link to comment
Share on other sites

Link to comment
Share on other sites

  • 3 months later...

i tried adding:

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)
        Local $x = 0
        Local $pOutput = 0
        Local $oOutput = 0
        While not $oAdapter.EnumOutputs($x,$pOutput) = $DXGI_ERROR_NOT_FOUND
            $oOutput = ObjCreateInterface($pOutput, $sIID_IDXGIAdapter, $sTag__IDXGIAdapter)
            ConsoleWrite("IsObj($oOutput): " & IsObj($oOutput) & @CRLF)
            $tOutputDescription = DllStructCreate($sTag_DXGI_ADAPTER_DESC)
            $oOutput.GetDesc(DllStructGetPtr($tOutputDescription))
            ConsoleWrite("Output: " & $oOutput.Size & @CRLF)
            $x += 1
        WEnd
        $oOutput = 0
        ConsoleWrite(@CRLF & @CRLF)
        $oAdapter = 0
    EndIf
    $i += 1
WEnd

but i can't get a adapter to show the connected monitors and their screensize. could you give me a hint how to create the needed dll struct?

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:-)
Link to comment
Share on other sites

  • 4 weeks later...

for future reference, i was able to create a c++ executable that forwards the part of the screen as html pixel data via named pipe to autoit.

https://github.com/jrsmile/DXGICapture2NamedPipe

it is far from polished but the concept works.

i would rather like to do it in AutoIT but so far no chance.

$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:-)
Link to comment
Share on other sites

Interestning, unfortunatelly beyond of my knowledge.
But I will keep an eye on this thread.
 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Hello @JRSmile I did not notice your message when you ask for help with get a adapter to show the connected monitors and their screensize. I'll try to look deeply later.

Nice project DXGICapture2NamedPipe.

 

Saludos

 

 

Link to comment
Share on other sites

i got around by converting the dxgi c++ example into a dll and using dllcalls to get the data i want.

@Danyfirex i still have the goal to scrap the dll and do it only in autoit with the desktop duplication api.

this evening i will update my github to represent a working sample.

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:-)
Link to comment
Share on other sites

I tedted the Dll seems to be working right using trancexx example. 

Between here is a step up for do it in raw autoit code. But I think the dll alternative is the best, because raw autoit code will slow down all.

;~ #AutoIt3Wrapper_UseX64=y
;~ https://www.purebasic.fr/german/viewtopic.php?f=3&t=30900
#include <WinAPI.au3>
Global Const $D3D11_SDK_VERSION = 7
Global Const $D3D_FEATURE_LEVEL_9_1 = 0
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;"


Global Const $sTag_IDXGIOutput = $sTag_DummyIDXGIObject & "GetDesc hresult(ptr); GetDisplayModeList hresult(int;uint;uint*;ptr); FindClosestMatchingMode hresult(ptr;ptr;ptr); " & _
        "WaitForVBlank hresult(); TakeOwnership hresult(); ReleaseOwnership hresult(); GetGammaControlCapabilities hresult(); SetGammaControl hresult(); " & _
        "GetGammaControl hresult() SetDisplaySurface hresult(); GetDisplaySurfaceData hresult(); GetFrameStatistics result();"
Global Const $sIID_IDXGIOutput = "{ae02eedb-c735-4690-8d52-5a8dc20213aa}"

Global Const $sTag_DXGI_OUTPUT_DESC = "wchar DeviceName[32];long Left;long Top;long Right;long Bottom;bool AttachedToDesktop;int Rotation;handle Monitor;"

;from IDXGIOutput
Global Const $sTag_IDXGIOutput1 = $sTag_IDXGIOutput & " GetDisplayModeList1 hresult(); FindClosestMatchingMode1 hresult(); GetDisplaySurfaceData1 hresult(ptr;ptr);" & _
        "DuplicateOutput hresult(ptr;ptr*);"
Global Const $sIID_IDXGIOutput1 = "{00cddea8-939b-4b83-a340-a685226666cc}"


Global Const $sTag_IDXGIOutputDuplication = $sTag_DummyIDXGIObject & "GetDesc hresult(ptr); AcquireNextFrame hresult(uint;ptr;ptr*); GetFrameDirtyRects(uint;ptr;uint*);" & _
        "GetFrameMoveRects hresult(uint;ptr;uint*); GetFramePointerShape hresult(uint;ptr*;uint*;ptr); MapDesktopSurface hresult(ptr); UnMapDesktopSurface hresult(); ReleaseFrame hresult();"
Global Const $sIID_IDXGIOutputDuplication = "{191cfac3-a341-470d-b26e-a864f428319c}"


Global Const $sCLSID_WICImagingFactory="{cacaf262-9370-4615-a13b-9f5539da4c0a}"
Global Const $sIID_IWICImagingFactory= "{ec5ec8a9-c395-4314-9c77-54d7a935ff70}"
Global Const $sTag_IWICImagingFactory="CreateDecoderFromFilename hresult();"


Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")


;~ DllOpen("DXGI.dll")
DllOpen("D3D11.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)



        Local $pOutput = 0
        Local $oOutput = 0
        Local $x = 0
        While Not $oAdapter.EnumOutputs($x, $pOutput) = $DXGI_ERROR_NOT_FOUND
            ConsoleWrite("$pOutput: " & $pOutput & @CRLF)
            $oOutput = ObjCreateInterface($pOutput, $sIID_IDXGIOutput, $sTag_IDXGIOutput)
            ConsoleWrite("IsObj($oOutput): " & IsObj($oOutput) & @CRLF)

            Local $tOutputDescription = DllStructCreate($sTag_DXGI_OUTPUT_DESC)
            $oOutput.GetDesc(DllStructGetPtr($tOutputDescription))
            ConsoleWrite(">>>>>>>>>>>Output Information<<<<<<<<<<<<<" & @CRLF)
            ConsoleWrite("DeviceName: " & $tOutputDescription.DeviceName & @CRLF)
            ConsoleWrite("Left: " & $tOutputDescription.Left & @CRLF)
            ConsoleWrite("Top: " & $tOutputDescription.Top & @CRLF)
            ConsoleWrite("Right: " & $tOutputDescription.Right & @CRLF)
            ConsoleWrite("Bottom: " & $tOutputDescription.Bottom & @CRLF)
            ConsoleWrite("AttachedToDesktop: " & $tOutputDescription.AttachedToDesktop & @CRLF)
            ConsoleWrite("Monitor: " & $tOutputDescription.Monitor & @CRLF)
            $x += 1

            If $tOutputDescription.AttachedToDesktop Then
                Local $pID3D11Device = 0
                Local $pID3D11DeviceContext = 0

                Local $aRet = DllCall("D3D11.dll", "long", "D3D11CreateDevice", "ptr", $pAdapter, "int", 0, _ ;D3D_DRIVER_TYPE_UNKNOWN
                        "handle", 0, "uint", 0, "ptr", 0, "uint", 0, "uint", $D3D11_SDK_VERSION, "ptr*", 0, "int", $D3D_FEATURE_LEVEL_9_1, "ptr*", 0)
                ConsoleWrite("D3D11CreateDevice: " & $aRet[0] & @TAB & "@error: " & @error & @CRLF)
                $pID3D11Device = $aRet[8]
                $pID3D11DeviceContext = $aRet[10]
                ConsoleWrite("$pD3D11Device: " & $pID3D11Device & @CRLF)
                ConsoleWrite("$pD3D11DeviceContext: " & $pID3D11DeviceContext & @CRLF)

;~              ;using GueryInterface
;~              Local $pOutput1 = 0
;~              $oOutput.QueryInterface($sIID_IDXGIOutput1, $pOutput1)
;~              Local $oOutput1 = ObjCreateInterface($pOutput1, $sIID_IDXGIOutput1, $sTag_IDXGIOutput1)
;~              ConsoleWrite("IsObj($oOutput1): " & IsObj($oOutput1) & @CRLF)
;~              ConsoleWrite("ObjName($oOutput1): " & ObjName($oOutput1) & @CRLF)
;~              Local $tOutputDescription1 = DllStructCreate($sTag_DXGI_OUTPUT_DESC)
;~              $oOutput1.GetDesc(DllStructGetPtr($tOutputDescription1))

;~                 ;using ObjCreateInterface
                Local $oOutput1 = ObjCreateInterface($oOutput(), $sIID_IDXGIOutput1, $sTag_IDXGIOutput1)
                Local $tOutputDescription1 = DllStructCreate($sTag_DXGI_OUTPUT_DESC)
                $oOutput1.GetDesc(DllStructGetPtr($tOutputDescription1))
                ConsoleWrite(">>>>>>>>>>>Output1 Information<<<<<<<<<<<<<" & @CRLF)
                ConsoleWrite("DeviceName: " & $tOutputDescription1.DeviceName & @CRLF)
                ConsoleWrite("Left: " & $tOutputDescription1.Left & @CRLF)
                ConsoleWrite("Top: " & $tOutputDescription1.Top & @CRLF)
                ConsoleWrite("Right: " & $tOutputDescription1.Right & @CRLF)
                ConsoleWrite("Bottom: " & $tOutputDescription1.Bottom & @CRLF)
                ConsoleWrite("AttachedToDesktop: " & $tOutputDescription1.AttachedToDesktop & @CRLF)
                ConsoleWrite("Monitor: " & $tOutputDescription1.Monitor & @CRLF)


                Local $pDXGIOutputDuplication = 0
                Local $oDXGIOutputDuplication = 0
                $oOutput1.DuplicateOutput($pID3D11Device, $pDXGIOutputDuplication)
                ConsoleWrite("$pDXGIOutputDuplication: " & $pDXGIOutputDuplication & @CRLF)

            EndIf

        WEnd
        ConsoleWrite(@CRLF & @CRLF)
        $oOutput = 0 ;free output
        $oAdapter = 0 ;free adapter
    EndIf
    $i += 1
WEnd


Local $oImagingFactory=ObjCreateInterface($sCLSID_WICImagingFactory,$sIID_IWICImagingFactory,$sTag_IWICImagingFactory)
ConsoleWrite("IsObj($oImagingFactory): " & IsObj($oImagingFactory) & @CRLF)



; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc


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

 

PD: some method tag need to be fixed because I was to lazy to set correct parameters type for each method.

Saludos 

Edited by Danyfirex
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...