junkew Posted September 26, 2017 Share Posted September 26, 2017 Basically all docs and links say // Call the method via late binding. // The parameter is passed by reference (VT_BSTR | VT_BYREF) obj.GetType().InvokeMember("SomeMethod", BindingFlags.InvokeMethod, null, obj, args, mods, null, null); But when we have returned generic collection $pscollection i am unable to invokemember tostring or count or ... FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
ptrex Posted September 26, 2017 Share Posted September 26, 2017 OK Thanks... I guess we best stop here unless someone else has a bright idea ? We have been too long looking for answers and not find any. Can be just a limitation of AutoIT or the CLR UDF Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
LarsJ Posted September 27, 2017 Share Posted September 27, 2017 You can try to ask this guy Lexikos in the AutoHotkey forum. In post 94 there is an example in ahk code that illustrates the problem. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
ptrex Posted September 27, 2017 Share Posted September 27, 2017 Thanks for the suggestion... but I will drop it for now and move on... Later this week or next week, I will publish in the final release thread what we have up till now. And also make a thread in the PowerShell section of the forum. Everything works to my expectation, except for the output of PSOBJECTS members to Console... Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
junkew Posted September 28, 2017 Share Posted September 28, 2017 (edited) Good suggestion I will sign in in that forum to (never used AHK). Over time people will do more nice tricks in bridging AutoIt with .NET for me its easier in C# to understand how to handle this then doing the same in AutoIt. Someone over time will find out how to do MSIL directly with either CLR.AU3 or DOTNET.AU3 As you can see in below MSIL part is System.Type.GetTypeFromHandle an important one to get the type of an instance Icall System.Type.GetTypeFromHandle callvirt System.Collections.Generic.Dictionary<System.Type,System.Reflection.PropertyInfo[]>.ContainsKey brfalse.s IL_002F ldarg.0 ldfld elementProperties ldtoken 01 00 00 1B call System.Type.GetTypeFromHandle callvirt System.Collections.Generic.Dictionary<System.Type,System.Reflection.PropertyInfo[]>.get_Item pop br.s IL_0053 ldarg.0 ldfld elementProperties ldtoken 01 00 00 1B call System.Type.GetTypeFromHandle ldtoken 01 00 00 1B call System.Type.GetTypeFromHandle call System.Type.GetProperties callvirt System.Collections.Generic.Dictionary<System.Type,System.Reflection.PropertyInfo[]>.set_Item ; Equivalent to GetType(TimeSpan) L_001d: ldtoken [mscorlib]System.TimeSpan L_0022: call [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle([mscorlib]System.RuntimeTypeHandle) ; This is the late-binding way of creating an empty TimeSpan. L_0027: call object [mscorlib]System.Activator::CreateInstance([mscorlib]System.Type) L_002c: unbox [mscorlib]System.TimeSpan L_0031: ldobj [mscorlib]System.TimeSpan L_0036: stloc.2 Its just a matter of understanding where C# compiler is dealing a lot of things directly in AutoIt you have to call all the reflection and compiler stuff yourself. Very interesting material but timeconsuming to read and tryout. All bits and pieces have been hit in this thread and no reason to believe that it cannot be done. So now and then I study this and spent some hours trying in AutoIt but must admit its so much easier in a visual studio debugging environment to understand then with dozens of consolewrites, etc.. I am learning a lot also from the CLR runtime last few months but its just a hobby and not a fulltime job ;-) Edited September 28, 2017 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
ptrex Posted September 28, 2017 Share Posted September 28, 2017 If you want to study more on this topic. This is some more interesting reading on the ins and outs of .NET CLR: https://www.codeproject.com/articles/20481/net-type-internals-from-a-microsoft-clr-perspecti Objects are discussed here : Quote The variable referring to an instance of a Reference Type is called Object Reference and is a pointer to the starting address of Reference Type instance + 4 bytes. The starting address of any Reference Type instance is a 4 byte value called sync block address and points to a location in a process-wide table that contains structures used for synchronizing access to instances of Reference Types. The next 4 bytes contains the address of a memory (AppDomain specific) that contains a structure holding the Method Table of the Reference Type for which the object is instantiated or points to. This Method Table in turn contains a reference to another structure, which holds the Runtime Type Information of the corresponding Reference Type. This is the complete CLR interfacing documentation : https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/hosting/clr-hosting-interfaces But to end here with my latest findings : If you uncomment the For $Item in $objPsCollection / Next part to loop through the members. You will notice that the script will NOT execute anymore the Switch command. $objPsCollection = $pObjectPS.EndInvoke($objAsync) ;~ For $Item in $objPsCollection ;~ ConsoleWrite($Item.members.value("ID") ;~ Next Switch $iOutput Case 0 ;~ ConsoleWrite( $objPsCollection & @CRLF) MsgBox(16,"PSHost","Output To Console is not working yet :-( ?" & @CRLF & @CRLF & " Best make a different OUTPUT option.") Case 1 Sleep(10000) ;~ WinWaitClose("") Case 3 MsgBox(0,"PSHost","File Output Ready on Desktop.") EndSwitch This means that in some way the For / Next leaves the script and is never returned ? That's why there's no ConsoleWrite feedback to the host. It finds the members and the loop works as you see while it takes the time it takes to loop. But this happens somewhere else , the reason WHY this happens is not clear. Does it have anything to do with MTA state the PowerShell runs in ? or something else this is not clear. I hope this can give some hints in getting a clue what is going on... Anyhow we are now 6 months further down the road with .NET CLR and I am very happy with the results ! Even if the CLR code is messy, I would not change a lot to it. It works apart from this ConsoleWrite Host part of it... I will now focus more on applying the CLR / PowerShell, rather then tryng to figure out how it works. If I run into something interesting I will still add stuff to this thread of course if it can help ... Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
junkew Posted September 28, 2017 Share Posted September 28, 2017 thx. more to read I was not able to do anything on the $objPsCollection It just dies AutoIt script whenever I try consolewrite($objPsCollection.ToString()) consolewrite($objPsCollection.Count()) or consolewrite($myType.Invokemethod("ToString",.....)) consolewrite($myType.Invokemethod("Count",.....)) I assume as its not comvisible AutoIt tries to do a QueryInterface which not exist(s) on all .NET objects (and should be reached then thru System.___Object interface logic where i do not have a clue on how to reach that in AutoIt so coming days will try out what dotnet.au3 is doing or try things in this thread with clr.AHK to see it in that library the concept on .net generic collections is working). So somehow on the $PSCollection its not creating the object methods reachable. And suppose $PSCollection is a pointerreference to an object then with below stuff I could make the ObjCreateInterface (just like @Danyfirex did for other base interfaces when we started this thread) struct __declspec(uuid("65074f7f-63c0-304e-af0a-d51741cb4a8d")) _Object : IDispatch { // // Raw methods provided by interface // virtual HRESULT __stdcall get_ToString ( /*[out,retval]*/ BSTR * pRetVal ) = 0; virtual HRESULT __stdcall Equals ( /*[in]*/ VARIANT obj, /*[out,retval]*/ VARIANT_BOOL * pRetVal ) = 0; virtual HRESULT __stdcall GetHashCode ( /*[out,retval]*/ long * pRetVal ) = 0; virtual HRESULT __stdcall GetType ( /*[out,retval]*/ struct _Type * * pRetVal ) = 0; }; https://stackoverflow.com/questions/1233468/unable-to-cast-com-object-of-type-exception FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
ptrex Posted September 28, 2017 Share Posted September 28, 2017 OK good to see you are taking it a bit further... we will hear from you when some progress on this pops up Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
junkew Posted February 12, 2021 Share Posted February 12, 2021 Maybe time to make progress on https://github.com/dotnet/docs/blob/master/docs/core/tutorials/netcore-hosting.md FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
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