Leaderboard
Popular Content
Showing content with the highest reputation on 03/24/2017 in all areas
-
The first AutoHotkey example (tst00.ahk about XPTable.dll assembly) is translated: ;#AutoIt3Wrapper_UseX64=y #include "SafeArray.au3" #include "Variant.au3" 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 Func _WinAPI_SetParent($hWndChild, $hWndParent) Local $aResult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWndChild, "hwnd", $hWndParent) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetParent Global Const $S_OK = 0 Global Const $sCLSID_CLRMetaHost = "{9280188d-0e8e-4867-b30c-7fa83884e8de}" Global Const $tCLSID_CLRMetaHost = _WinAPI_CLSIDFromString($sCLSID_CLRMetaHost) Global Const $sIID_ICLRMetaHost = "{d332db9e-b9b3-4125-8207-a14884f53216}" Global Const $tIID_ICLRMetaHost = _WinAPI_CLSIDFromString($sIID_ICLRMetaHost) Global Const $sTag_ICLRMetaHost = _ "GetRuntime hresult(wstr;struct*;ptr);" & _ "GetVersionFromFile hresult(ptr;ptr;ptr);" & _ "EnumerateInstalledRuntimes hresult(ptr);" & _ "EnumerateLoadedRuntimes hresult(ptr;ptr);" & _ "RequestRuntimeLoadedNotification hresult(ptr,ptr,ptr):" & _ "QueryLegacyV2RuntimeBinding hresult(ptr;ptr);" & _ "ExitProcess hresult(int);" Global Const $sIID_ICLRRuntimeInfo = "{BD39D1D2-BA2F-486a-89B0-B4B0CB466891}" Global Const $tIID_ICLRRuntimeInfo = _WinAPI_CLSIDFromString($sIID_ICLRRuntimeInfo) Global Const $sTag_ICLRRuntimeInfo = _ "GetVersionString hresult(ptr;ptr);" & _ "GetRuntimeDirectory hresult(ptr;ptr);" & _ "IsLoaded hresult(ptr;ptr);" & _ "LoadErrorString hresult(ptr;ptr;ptr;ptr);" & _ "LoadLibrary hresult(ptr;ptr);" & _ "GetProcAddress hresult(ptr;ptr);" & _ "GetInterface hresult(ptr;ptr;ptr);" & _ "IsLoadable hresult(Bool*);" & _ "SetDefaultStartupFlags hresult(ptr;ptr);" & _ "GetDefaultStartupFlags hresult(ptr;ptr;ptr);" & _ "BindAsLegacyV2Runtime hresult();" & _ "IsStarted hresult(ptr;ptr);" Global Const $sCLSID_CLRRuntimeHost = "{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}" Global Const $tCLSID_CLRRuntimeHost = _WinAPI_CLSIDFromString($sCLSID_CLRRuntimeHost) Global Const $sIID_ICLRRuntimeHost = "{90F1A06C-7712-4762-86B5-7A5EBA6BDB02}" Global Const $tIID_ICLRRuntimeHost = _WinAPI_CLSIDFromString($sIID_ICLRRuntimeHost) Global Const $sTag_ICLRRuntimeHost = _ "Start hresult();" & _ "Stop hresult();" & _ "SetHostControl hresult(ptr);" & _ "GetCLRControl hresult(ptr*);" & _ "UnloadAppDomain hresult(ptr;ptr);" & _ "ExecuteInAppDomain hresult(ptr;ptr;ptr);" & _ "GetCurrentAppDomainId hresult(ptr);" & _ "ExecuteApplication hresult(ptr;ptr;ptr;ptr;ptr;ptr);" & _ "ExecuteInDefaultAppDomain hresult(wstr;wstr;wstr;wstr;ptr*);" Global Const $sCLSID_CorRuntimeHost = "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}" Global Const $tCLSID_CorRuntimeHost = _WinAPI_CLSIDFromString($sCLSID_CorRuntimeHost) Global Const $sIID_ICorRuntimeHost = "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}" Global Const $tIID_ICorRuntimeHost = _WinAPI_CLSIDFromString($sIID_ICorRuntimeHost) Global Const $sTag_ICorRuntimeHost = _ "CreateLogicalThreadState hresult();" & _ "DeleteLogicalThreadState hresult();" & _ "SwitchInLogicalThreadState hresult();" & _ "SwitchOutLogicalThreadState hresult();" & _ "LocksHeldByLogicalThread hresult();" & _ "MapFile hresult();" & _ "GetConfiguration hresult();" & _ "Start hresult();" & _ "Stop hresult();" & _ "CreateDomain hresult();" & _ "GetDefaultDomain hresult(ptr*);" & _ "EnumDomains hresult();" & _ "NextDomain hresult();" & _ "CloseEnum hresult();" & _ "CreateDomainEx hresult();" & _ "CreateDomainSetup hresult();" & _ "CreateEvidence hresult();" & _ "UnloadDomain hresult();" & _ "CurrentDomain hresult();" Global Const $sIID_IAppDomain = "{05F696DC-2B29-3663-AD8B-C4389CF2A713}" Global Const $sTag_IAppDomain = _ "GetTypeInfoCount hresult();" & _ "GetTypeInfo hresult();" & _ "GetIDsOfNames hresult();" & _ "Invoke hresult();" & _ "get_ToString hresult();" & _ "Equals hresult();" & _ "GetHashCode hresult();" & _ "GetType hresult(ptr*);" & _ "InitializeLifetimeService hresult();" & _ "GetLifetimeService hresult();" & _ "get_Evidence hresult();" & _ "add_DomainUnload hresult();" & _ "remove_DomainUnload hresult();" & _ "add_AssemblyLoad hresult();" & _ "remove_AssemblyLoad hresult();" & _ "add_ProcessExit hresult();" & _ "remove_ProcessExit hresult();" & _ "add_TypeResolve hresult();" & _ "remove_TypeResolve hresult();" & _ "add_ResourceResolve hresult();" & _ "remove_ResourceResolve hresult();" & _ "add_AssemblyResolve hresult();" & _ "remove_AssemblyResolve hresult();" & _ "add_UnhandledException hresult();" & _ "remove_UnhandledException hresult();" & _ "DefineDynamicAssembly hresult();" & _ "DefineDynamicAssembly_2 hresult();" & _ "DefineDynamicAssembly_3 hresult();" & _ "DefineDynamicAssembly_4 hresult();" & _ "DefineDynamicAssembly_5 hresult();" & _ "DefineDynamicAssembly_6 hresult();" & _ "DefineDynamicAssembly_7 hresult();" & _ "DefineDynamicAssembly_8 hresult();" & _ "DefineDynamicAssembly_9 hresult();" & _ "CreateInstance hresult(bstr;bstr;object*);" & _ "CreateInstanceFrom hresult();" & _ "CreateInstance_2 hresult();" & _ "CreateInstanceFrom_2 hresult();" & _ "CreateInstance_3 hresult();" & _ "CreateInstanceFrom_3 hresult();" & _ "Load hresult();" & _ "Load_2 hresult();" & _ "Load_3 hresult();" & _ "Load_4 hresult();" & _ "Load_5 hresult();" & _ "Load_6 hresult();" & _ "Load_7 hresult();" & _ "ExecuteAssembly hresult();" & _ "ExecuteAssembly_2 hresult();" & _ "ExecuteAssembly_3 hresult();" & _ "get_FriendlyName hresult();" & _ "get_BaseDirectory hresult();" & _ "get_RelativeSearchPath hresult();" & _ "get_ShadowCopyFiles hresult();" & _ "GetAssemblies hresult();" & _ "AppendPrivatePath hresult();" & _ "ClearPrivatePath ) = 0; hresult();" & _ "SetShadowCopyPath hresult();" & _ "ClearShadowCopyPath ) = 0; hresult();" & _ "SetCachePath hresult();" & _ "SetData hresult();" & _ "GetData hresult();" & _ "SetAppDomainPolicy hresult();" & _ "SetThreadPrincipal hresult();" & _ "SetPrincipalPolicy hresult();" & _ "DoCallBack hresult();" & _ "get_DynamicDirectory hresult();" Global Const $sIID_IType = "{BCA8B44D-AAD6-3A86-8AB7-03349F4F2DA2}" Global Const $sTag_IType = _ "GetTypeInfoCount hresult();" & _ "GetTypeInfo hresult();" & _ "GetIDsOfNames hresult();" & _ "Invoke hresult();" & _ "get_ToString hresult();" & _ "Equals hresult();" & _ "GetHashCode hresult();" & _ "GetType hresult();" & _ "get_MemberType hresult();" & _ "get_name hresult();" & _ "get_DeclaringType hresult();" & _ "get_ReflectedType hresult();" & _ "GetCustomAttributes hresult();" & _ "GetCustomAttributes_2 hresult();" & _ "IsDefined hresult();" & _ "get_Guid hresult();" & _ "get_Module hresult();" & _ "get_Assembly hresult(ptr*);" & _ "get_TypeHandle hresult();" & _ "get_FullName hresult();" & _ "get_Namespace hresult();" & _ "get_AssemblyQualifiedName hresult();" & _ "GetArrayRank hresult();" & _ "get_BaseType hresult();" & _ "GetConstructors hresult();" & _ "GetInterface hresult();" & _ "GetInterfaces hresult();" & _ "FindInterfaces hresult();" & _ "GetEvent hresult();" & _ "GetEvents hresult();" & _ "GetEvents_2 hresult();" & _ "GetNestedTypes hresult();" & _ "GetNestedType hresult();" & _ "GetMember hresult();" & _ "GetDefaultMembers hresult();" & _ "FindMembers hresult();" & _ "GetElementType hresult();" & _ "IsSubclassOf hresult();" & _ "IsInstanceOfType hresult();" & _ "IsAssignableFrom hresult();" & _ "GetInterfaceMap hresult();" & _ "GetMethod hresult();" & _ "GetMethod_2 hresult();" & _ "GetMethods hresult();" & _ "GetField hresult();" & _ "GetFields hresult();" & _ "GetProperty hresult();" & _ "GetProperty_2 hresult();" & _ "GetProperties hresult();" & _ "GetMember_2 hresult();" & _ "GetMembers hresult();" & _ "InvokeMember hresult();" & _ "get_UnderlyingSystemType hresult();" & _ "InvokeMember_2 hresult();" & _ "InvokeMember_3 hresult(bstr;int;ptr;variant;ptr;variant*);" & _ "GetConstructor hresult();" & _ "GetConstructor_2 hresult();" & _ "GetConstructor_3 hresult();" & _ "GetConstructors_2 hresult();" & _ "get_TypeInitializer hresult();" & _ "GetMethod_3 hresult();" & _ "GetMethod_4 hresult();" & _ "GetMethod_5 hresult();" & _ "GetMethod_6 hresult();" & _ "GetMethods_2 hresult();" & _ "GetField_2 hresult();" & _ "GetFields_2 hresult();" & _ "GetInterface_2 hresult();" & _ "GetEvent_2 hresult();" & _ "GetProperty_3 hresult();" & _ "GetProperty_4 hresult();" & _ "GetProperty_5 hresult();" & _ "GetProperty_6 hresult();" & _ "GetProperty_7 hresult();" & _ "GetProperties_2 hresult();" & _ "GetNestedTypes_2 hresult();" & _ "GetNestedType_2 hresult();" & _ "GetMember_3 hresult();" & _ "GetMembers_2 hresult();" & _ "get_Attributes hresult();" & _ "get_IsNotPublic hresult();" & _ "get_IsPublic hresult();" & _ "get_IsNestedPublic hresult();" & _ "get_IsNestedPrivate hresult();" & _ "get_IsNestedFamily hresult();" & _ "get_IsNestedAssembly hresult();" & _ "get_IsNestedFamANDAssem hresult();" & _ "get_IsNestedFamORAssem hresult();" & _ "get_IsAutoLayout hresult();" & _ "get_IsLayoutSequential hresult();" & _ "get_IsExplicitLayout hresult();" & _ "get_IsClass hresult();" & _ "get_IsInterface hresult();" & _ "get_IsValueType hresult();" & _ "get_IsAbstract hresult();" & _ "get_IsSealed hresult();" & _ "get_IsEnum hresult();" & _ "get_IsSpecialName hresult();" & _ "get_IsImport hresult();" & _ "get_IsSerializable hresult();" & _ "get_IsAnsiClass hresult();" & _ "get_IsUnicodeClass hresult();" & _ "get_IsAutoClass hresult();" & _ "get_IsArray hresult();" & _ "get_IsByRef hresult();" & _ "get_IsPointer hresult();" & _ "get_IsPrimitive hresult();" & _ "get_IsCOMObject hresult();" & _ "get_HasElementType hresult();" & _ "get_IsContextful hresult();" & _ "get_IsMarshalByRef hresult();" & _ "Equals_2 hresult();" ; InvokeMember, InvokeMember_2, InvokeMember_3 Global Const $BindingFlags_Default = 0x0000 Global Const $BindingFlags_IgnoreCase = 0x0001 Global Const $BindingFlags_DeclaredOnly = 0x0002 Global Const $BindingFlags_Instance = 0x0004 Global Const $BindingFlags_Static = 0x0008 Global Const $BindingFlags_Public = 0x0010 Global Const $BindingFlags_NonPublic = 0x0020 Global Const $BindingFlags_FlattenHierarchy = 0x0040 Global Const $BindingFlags_InvokeMethod = 0x0100 Global Const $BindingFlags_CreateInstance = 0x0200 Global Const $BindingFlags_GetField = 0x0400 Global Const $BindingFlags_SetField = 0x0800 Global Const $BindingFlags_GetProperty = 0x1000 Global Const $BindingFlags_SetProperty = 0x2000 Global Const $BindingFlags_PutDispProperty = 0x4000 Global Const $BindingFlags_PutRefDispProperty = 0x8000 Global Const $BindingFlags_ExactBinding = 0x00010000 Global Const $BindingFlags_SuppressChangeType = 0x00020000 Global Const $BindingFlags_OptionalParamBinding = 0x00040000 Global Const $BindingFlags_IgnoreReturn = 0x01000000 Global Const $sIID_IDispatch = "{00020400-0000-0000-C000-000000000046}" Global Const $sTag_IDispatch = _ "GetTypeInfoCount hresult(dword*);" & _ ; Retrieves the number of type information interfaces that an object provides (either 0 or 1). "GetTypeInfo hresult(dword;dword;ptr*);" & _ ; Gets the type information for an object. "GetIDsOfNames hresult(ptr;ptr;dword;dword;ptr);" & _ ; Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs, which can be used on subsequent calls to Invoke. "Invoke hresult(dword;ptr;dword;word;ptr;ptr;ptr;ptr);" ; Provides access to properties and methods exposed by an object. Global Const $sIID_IAssembly = "{17156360-2F1A-384A-BC52-FDE93C215C5B}" Global Const $sTag_IAssembly = _ $sTag_IDispatch & _ "get_ToString hresult();" & _ "Equals hresult();" & _ "GetHashCode hresult();" & _ "GetType hresult(ptr*);" & _ "get_CodeBase hresult();" & _ "get_EscapedCodeBase hresult();" & _ "GetName hresult();" & _ "GetName_2 hresult();" & _ "get_FullName hresult();" & _ "get_EntryPoint hresult();" & _ "GetType_2 hresult();" & _ "GetType_3 hresult();" & _ "GetExportedTypes hresult();" & _ "GetTypes hresult();" & _ "GetManifestResourceStream hresult();" & _ "GetManifestResourceStream_2 hresult();" & _ "GetFile hresult();" & _ "GetFiles hresult();" & _ "GetFiles_2 hresult();" & _ "GetManifestResourceNames hresult();" & _ "GetManifestResourceInfo hresult();" & _ "get_Location hresult();" & _ "get_Evidence hresult();" & _ "GetCustomAttributes hresult();" & _ "GetCustomAttributes_2 hresult();" & _ "IsDefined hresult();" & _ "GetObjectData hresult();" & _ "add_ModuleResolve hresult();" & _ "remove_ModuleResolve hresult();" & _ "GetType_4 hresult();" & _ "GetSatelliteAssembly hresult();" & _ "GetSatelliteAssembly_2 hresult();" & _ "LoadModule hresult();" & _ "LoadModule_2 hresult();" & _ "CreateInstance hresult();" & _ "CreateInstance_2 hresult(bstr;bool;variant*);" & _ "CreateInstance_3 hresult(bstr;bool;int;ptr;ptr;ptr;ptr;variant*);" & _ "GetLoadedModules hresult();" & _ "GetLoadedModules_2 hresult();" & _ "GetModules hresult();" & _ "GetModules_2 hresult();" & _ "GetModule hresult();" & _ "GetReferencedAssemblies hresult();" & _ "get_GlobalAssemblyCache hresult();" Example() Func Example() Local $hMSCorEE = DllOpen("MSCorEE.DLL") Local $aRet = DllCall($hMSCorEE, "long", "CLRCreateInstance", "struct*", $tCLSID_CLRMetaHost, "struct*", $tIID_ICLRMetaHost, "ptr*", 0) If $aRet[0] = $S_OK Then Local $pClrHost = $aRet[3] Local $oClrHost = ObjCreateInterface($pClrHost, $sIID_ICLRMetaHost, $sTag_ICLRMetaHost) ConsoleWrite(">oClrHost: " & IsObj($oClrHost) & @CRLF) Local $sNETFrameworkVersion = "v4.0.30319" Local $tCLRRuntimeInfo = DllStructCreate("ptr") $oClrHost.GetRuntime($sNETFrameworkVersion, $tIID_ICLRRuntimeInfo, DllStructGetPtr($tCLRRuntimeInfo)) Local $pCLRRuntimeInfo = DllStructGetData($tCLRRuntimeInfo, 1) ConsoleWrite(">pCLRRuntimeInfo: " & $pCLRRuntimeInfo & @CRLF) Local $oCLRRuntimeInfo = ObjCreateInterface($pCLRRuntimeInfo, $sIID_ICLRRuntimeInfo, $sTag_ICLRRuntimeInfo) ConsoleWrite(">oCLRRuntimeInfo: " & IsObj($oCLRRuntimeInfo) & @CRLF) Local $isIsLoadable = 0 $oCLRRuntimeInfo.IsLoadable($isIsLoadable) ConsoleWrite(">IsLoadable: " & $isIsLoadable & @CRLF) If $isIsLoadable Then Local $tCLRRuntimeHost = DllStructCreate("ptr") $oCLRRuntimeInfo.GetInterface(DllStructGetPtr($tCLSID_CLRRuntimeHost), DllStructGetPtr($tIID_ICLRRuntimeHost), DllStructGetPtr($tCLRRuntimeHost)) Local $pCLRRuntimeHost = DllStructGetData($tCLRRuntimeHost, 1) ConsoleWrite(">pCLRRuntimeHost: " & $pCLRRuntimeHost & @CRLF) Local $oCLRRuntimeHost = ObjCreateInterface($pCLRRuntimeHost, $sIID_ICLRRuntimeHost, $sTag_ICLRRuntimeHost) ConsoleWrite(">oCLRRuntimeHost: " & IsObj($oCLRRuntimeHost) & @CRLF) $oCLRRuntimeHost.Start() ;Local $iRet = 0 ;$oCLRRuntimeHost.ExecuteInDefaultAppDomain(@ScriptDir & "\C#Library.dll", "ClassLibraryDemo.ClassDemo", "NetMsgBox", "AutoIt Rocks!!! " & @CRLF & "Danyfirex does too lol!!!", $iRet) ;ConsoleWrite(">Ret: " & $iRet & @CRLF) Local $tCorRuntimeHost = DllStructCreate("ptr") $oCLRRuntimeInfo.GetInterface(DllStructGetPtr($tCLSID_CorRuntimeHost), DllStructGetPtr($tIID_ICorRuntimeHost), DllStructGetPtr($tCorRuntimeHost)) Local $pCorRuntimeHost = DllStructGetData($tCorRuntimeHost, 1) ;ConsoleWrite("$pCorRuntimeHost = " & $pCorRuntimeHost & @CRLF) Local $oCorRuntimeHost = ObjCreateInterface($pCorRuntimeHost, $sIID_ICorRuntimeHost, $sTag_ICorRuntimeHost) ConsoleWrite("IsObj( $oCorRuntimeHost ) = " & IsObj($oCorRuntimeHost) & @CRLF) $oCorRuntimeHost.Start() ; tst00.ahk ; CLR_LoadLibrary ; assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args) Local $pAppDomain = 0 $oCorRuntimeHost.GetDefaultDomain($pAppDomain) ConsoleWrite("$pAppDomain = " & Ptr($pAppDomain) & @CRLF) Local $oAppDomain = ObjCreateInterface($pAppDomain, $sIID_IAppDomain, $sTag_IAppDomain) ConsoleWrite("IsObj( $oAppDomain ) = " & IsObj($oAppDomain) & @CRLF) Local $pType $oAppDomain.GetType( $pType ) ConsoleWrite( "$pType = " & Ptr( $pType ) & @CRLF ) Local $oType = ObjCreateInterface( $pType, $sIID_IType, $sTag_IType ) ConsoleWrite( "IsObj( $oType ) = " & IsObj( $oType ) & @CRLF ) Local $pAssembly $oType.get_Assembly( $pAssembly ) ConsoleWrite( "$pAssembly = " & Ptr( $pAssembly ) & @CRLF ) Local $oAssembly = ObjCreateInterface( $pAssembly, $sIID_IAssembly, $sTag_IAssembly ) ConsoleWrite( "IsObj( $oAssembly ) = " & IsObj( $oAssembly ) & @CRLF ) Local $pAssemblyType $oAssembly.GetType( $pAssemblyType ) ConsoleWrite( "$pAssemblyType = " & Ptr( $pAssemblyType ) & @CRLF ) Local $oAssemblyType = ObjCreateInterface( $pAssemblyType, $sIID_IType, $sTag_IType ) ConsoleWrite( "IsObj( $oAssemblyType ) = " & IsObj( $oAssemblyType ) & @CRLF ) ; args := ComObjArray(0xC, 1), args[0] := "XPTable.dll" Local $tSafeArrayBound = DllStructCreate( $tagSAFEARRAYBOUND ) Local $pSafeArray, $pSafeArrayData DllStructSetData( $tSafeArrayBound, "cElements", 1 ) DllStructSetData( $tSafeArrayBound, "lLbound", 0 ) $pSafeArray = SafeArrayCreate( $VT_VARIANT, 1, $tSafeArrayBound ) SafeArrayAccessData( $pSafeArray, $pSafeArrayData ) DllStructSetData( DllStructCreate( "word", $pSafeArrayData ), 1, $VT_BSTR ) DllStructSetData( DllStructCreate( "ptr", $pSafeArrayData + 8 ), 1, SysAllocString( "XPTable.dll" ) ) SafeArrayUnaccessData( $pSafeArray ) Local $pXPTable $oAssemblyType.InvokeMember_3( "LoadFrom", 0x158, 0, 0, $pSafeArray, $pXPTable ) ConsoleWrite( "$pXPTable = " & Ptr( $pXPTable ) & @CRLF ) Local $oXPTable = ObjCreateInterface( $pXPTable, $sIID_IAssembly, $sTag_IAssembly ) ConsoleWrite( "IsObj( $oXPTable ) = " & IsObj( $oXPTable ) & @CRLF ) ; table := CLR_CreateObject(xptables,"XPTable.Models.Table") ; columnModel := CLR_CreateObject(xptables,"XPTable.Models.ColumnModel") ; tableModel := CLR_CreateObject(xptables,"XPTable.Models.TableModel") Local $oTable, $oColumnModel, $oTableModel $oXPTable.CreateInstance_2( "XPTable.Models.Table", True, $oTable ) $oXPTable.CreateInstance_2( "XPTable.Models.ColumnModel", True, $oColumnModel ) $oXPTable.CreateInstance_2( "XPTable.Models.TableModel", True, $oTableModel ) ConsoleWrite( "IsObj( $oTable ) = " & IsObj( $oTable ) & @CRLF ) ConsoleWrite( "IsObj( $oColumnModel ) = " & IsObj( $oColumnModel ) & @CRLF ) ConsoleWrite( "IsObj( $oTableModel ) = " & IsObj( $oTableModel ) & @CRLF ) $oTable.ColumnModel() = $oColumnModel $oTable.TableModel() = $oTableModel ; static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0) Local $pSAEmpty, $tSAB = DllStructCreate( $tagSAFEARRAYBOUND ) DllStructSetData( $tSAB, "cElements", 0 ) DllStructSetData( $tSAB, "lLbound", 0 ) $pSAEmpty = SafeArrayCreate( $VT_VARIANT, 0, $tSAB ) ; columnModel.Columns.Add(CLR_CreateObject(xptables, "XPTable.Models.TextColumn", "MyTextColumn")) ; columnModel.Columns.Add(CLR_CreateObject(xptables, "XPTable.Models.CheckBoxColumn", "MyCheckBoxColumn")) ; columnModel.Columns.Add(CLR_CreateObject(xptables, "XPTable.Models.ButtonColumn", "MyButtonColumn")) Local $oColumn0, $oColumn1, $oColumn2 $oXPTable.CreateInstance_3( "XPTable.Models.TextColumn", True, 0, 0, CreateSafeArray( "MyTextColumn" ), 0, $pSAEmpty, $oColumn0 ) $oXPTable.CreateInstance_3( "XPTable.Models.CheckBoxColumn", True, 0, 0, CreateSafeArray( "CheckBoxColumn" ), 0, $pSAEmpty, $oColumn1 ) $oXPTable.CreateInstance_3( "XPTable.Models.ButtonColumn", True, 0, 0, CreateSafeArray( "MyButtonColumn" ), 0, $pSAEmpty, $oColumn2 ) ConsoleWrite( "IsObj( $oColumn0 ) = " & IsObj( $oColumn0 ) & @CRLF ) ConsoleWrite( "IsObj( $oColumn1 ) = " & IsObj( $oColumn1 ) & @CRLF ) ConsoleWrite( "IsObj( $oColumn2 ) = " & IsObj( $oColumn2 ) & @CRLF ) $oColumnModel.Columns.Add( $oColumn0 ) $oColumnModel.Columns.Add( $oColumn1 ) $oColumnModel.Columns.Add( $oColumn2 ) ConsoleWrite( "VisibleColumnCount = " & $oColumnModel.VisibleColumnCount() & @CRLF ) Local $oRow $oXPTable.CreateInstance_2( "XPTable.Models.Row", True, $oRow ) ConsoleWrite( "IsObj( $oRow ) = " & IsObj( $oRow ) & @CRLF ) $oTableModel.Rows.Add( $oRow ) ConsoleWrite( "Rows = " & $oTableModel.Rows.Count() & @CRLF ) ; tableModel.Rows.Item(0).Cells.Add(CLR_CreateObject(xptables, "XPTable.Models.Cell", "MyCell1")) ; tableModel.Rows.Item(0).Cells.Add(CLR_CreateObject(xptables, "XPTable.Models.Cell", "MyCheckbox1", true)) ; tableModel.Rows.Item(0).Cells.Add(CLR_CreateObject(xptables, "XPTable.Models.Cell", "MyButton1")) Local $oCell0, $oCell1, $oCell2 $oXPTable.CreateInstance_3( "XPTable.Models.Cell", True, 0, 0, CreateSafeArray( "MyCell1" ), 0, $pSAEmpty, $oCell0 ) $oXPTable.CreateInstance_3( "XPTable.Models.Cell", True, 0, 0, CreateSafeArray( "MyCheckbox1", True ), 0, $pSAEmpty, $oCell1 ) $oXPTable.CreateInstance_3( "XPTable.Models.Cell", True, 0, 0, CreateSafeArray( "MyButton1" ), 0, $pSAEmpty, $oCell2 ) ConsoleWrite( "IsObj( $oCell0 ) = " & IsObj( $oCell0 ) & @CRLF ) ConsoleWrite( "IsObj( $oCell1 ) = " & IsObj( $oCell1 ) & @CRLF ) ConsoleWrite( "IsObj( $oCell2 ) = " & IsObj( $oCell2 ) & @CRLF ) $oTableModel.Rows.Item(0).Cells.Add( $oCell0 ) $oTableModel.Rows.Item(0).Cells.Add( $oCell1 ) $oTableModel.Rows.Item(0).Cells.Add( $oCell2 ) ConsoleWrite( "Cells = " & $oTableModel.Rows.Item(0).Cells.Count() & @CRLF ) $oTable.Left() = 10 $oTable.Top() = 10 $oTable.Width() = 300 $oTable.Height() = 200 Local $hTable = $oTable.Handle() Local $hGui = GUICreate( "XPTable", 320, 220 ) _WinAPI_SetParent( $hTable, $hGui ) GUISetState() Do Until GUIGetMsg() = -3 ; $GUI_EVENT_CLOSE EndIf EndIf DllClose($hMSCorEE) EndFunc Func CreateSafeArray( $string, $bool = Default ) Local $tSafeArrayBound = DllStructCreate( $tagSAFEARRAYBOUND ) Local $pSafeArray, $pSafeArrayData DllStructSetData( $tSafeArrayBound, "cElements", $bool = Default ? 1 : 2 ) DllStructSetData( $tSafeArrayBound, "lLbound", 0 ) $pSafeArray = SafeArrayCreate( $VT_VARIANT, 1, $tSafeArrayBound ) SafeArrayAccessData( $pSafeArray, $pSafeArrayData ) DllStructSetData( DllStructCreate( "word", $pSafeArrayData ), 1, $VT_BSTR ) DllStructSetData( DllStructCreate( "ptr", $pSafeArrayData + 8 ), 1, SysAllocString( $string ) ) If $bool Then $pSafeArrayData += @AutoItX64 ? 24 : 16 DllStructSetData( DllStructCreate( "word", $pSafeArrayData ), 1, $VT_BOOL ) DllStructSetData( DllStructCreate( "short", $pSafeArrayData + 8 ), 1, $bool ) EndIf SafeArrayUnaccessData( $pSafeArray ) Return $pSafeArray EndFunc Since you need Variant and SafeArray UDFs I've included all code in the zip. Run tst00.au3 in SciTE. You still have to download XPTable.dll. See post 59. Danyfirex you are right. It was easy. XPTable.7z1 point
-
nlta1992, Something like this perhaps? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Array to hold button ControlIDs Global $aButton[11] $hGUI = GUICreate("Test", 500, 500) ; A double loop to space out the buttons - but you could very easily have a single one instead For $i = 0 To 1 For $j = 1 To 5 $iIndex = ($i * 5) + $j ; Create button using a suitable algorithm to locate it $aButton[$iIndex] = GUICtrlCreateButton("Button " & $iIndex, 10 + (250 * $i), ($j * 50) - 30, 80, 30) Next Next GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case Else ; See if a button was pressed For $i = 1 To 10 If $iMsg = $aButton[$i] Then ; Do what is necessary MsgBox($MB_SYSTEMMODAL, "Pressed", "Button " & $i) ; No point in looking further ExitLoop EndIf Next EndSwitch WEnd M231 point
-
What trouble are you having? Personally I would use _VersionCompare something like: #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <Misc.au3> ; Here we go! ;########################################################################################################## ;Declare variables Global $RegKey86, $RegKey64, $RegValueName, $RegValueData, $CheckVersion86, $CheckVersion64 ; 7Zip ;########################################################################################################## _7Zip_Function() Func _7Zip_Function() ; Registry location and values that are checked for current software version ; Ensure the x64 key is preceeded with 'HKLM64' $RegKey86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegKey64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegValueName="DisplayVersion" $RegValueData="16.04" ; Excecution ; --------------------------------------------------------------------------------------------------------- If _RegVersionCompare($RegKey64, $RegValueName, $RegValueData) = 1 Then _UninstallOldVer() _InstallSW() EndIf EndFunc ;==>_7Zip_Function ; Functions ;########################################################################################################## Func _RegVersionCompare($sRegHive, $sRegKey, $sRegValue) Local $iVersionCompare = _VersionCompare(RegRead($sRegHive, $sRegKey), $sRegValue) Switch $iVersionCompare Case 0 Return 0 Case 1 Return 0 Case -1 Return 1 EndSwitch EndFunc ;==>CheckSW1 point
-
GUI for cmail command line utility
argumentum reacted to MattHiggs for a topic
**Updated: Original post updated. Fixes error which causes the "new line" character to break the script. Working perfectly well now.1 point -
Hello. Nice find Larsj I think it's no hard to traslate to AutoIt Maybe I'll do later. (I'm busy right now.) Also Here is the 39#'s Stack Object Example. ;~ #AutoIt3Wrapper_UseX64=y #include <Memory.au3> Global Const $S_OK = 0 Global Const $sTag_CLRMetaHost = _ "GetRuntime hresult(wstr;struct*;ptr);" & _ "GetVersionFromFile hresult(ptr;ptr;ptr);" & _ "EnumerateInstalledRuntimes hresult(ptr);" & _ "EnumerateLoadedRuntimes hresult(ptr;ptr);" & _ "RequestRuntimeLoadedNotification hresult(ptr,ptr,ptr):" & _ "QueryLegacyV2RuntimeBinding hresult(ptr;ptr);" & _ "ExitProcess hresult(int);" Global Const $sTag_CLRRuntimeInfo = _ "GetVersionString hresult(ptr;ptr);" & _ "GetRuntimeDirectory hresult(ptr;ptr);" & _ "IsLoaded hresult(ptr;ptr);" & _ "LoadErrorString hresult(ptr;ptr;ptr;ptr);" & _ "LoadLibrary hresult(ptr;ptr);" & _ "GetProcAddress hresult(ptr;ptr);" & _ "GetInterface hresult(ptr;ptr;ptr);" & _ "IsLoadable hresult(Bool*);" & _ "SetDefaultStartupFlags hresult(ptr;ptr);" & _ "GetDefaultStartupFlags hresult(ptr;ptr;ptr);" & _ "BindAsLegacyV2Runtime hresult();" & _ "IsStarted hresult(ptr;ptr);" Global Const $sTag_CLRRuntimeHost = _ "Start hresult();" & _ "Stop hresult();" & _ "SetHostControl hresult(ptr);" & _ "GetCLRControl hresult(ptr*);" & _ "UnloadAppDomain hresult(ptr;ptr);" & _ "ExecuteInAppDomain hresult(ptr;ptr;ptr);" & _ "GetCurrentAppDomainId hresult(ptr);" & _ "ExecuteApplication hresult(ptr;ptr;ptr;ptr;ptr;ptr);" & _ "ExecuteInDefaultAppDomain hresult(wstr;wstr;wstr;wstr;ptr*);" Global Const $sIID_AppDomain = "{05F696DC-2B29-3663-AD8B-C4389CF2A713}" Global Const $sTag_AppDomain = _ "GetTypeInfoCount hresult();" & _ "GetTypeInfo hresult();" & _ "GetIDsOfNames hresult();" & _ "Invoke hresult();" & _ "get_ToString hresult();" & _ "Equals hresult();" & _ "GetHashCode hresult();" & _ "GetType hresult();" & _ "InitializeLifetimeService hresult();" & _ "GetLifetimeService hresult();" & _ "get_Evidence hresult();" & _ "add_DomainUnload hresult();" & _ "remove_DomainUnload hresult();" & _ "add_AssemblyLoad hresult();" & _ "remove_AssemblyLoad hresult();" & _ "add_ProcessExit hresult();" & _ "remove_ProcessExit hresult();" & _ "add_TypeResolve hresult();" & _ "remove_TypeResolve hresult();" & _ "add_ResourceResolve hresult();" & _ "remove_ResourceResolve hresult();" & _ "add_AssemblyResolve hresult();" & _ "remove_AssemblyResolve hresult();" & _ "add_UnhandledException hresult();" & _ "remove_UnhandledException hresult();" & _ "DefineDynamicAssembly hresult();" & _ "DefineDynamicAssembly_2 hresult();" & _ "DefineDynamicAssembly_3 hresult();" & _ "DefineDynamicAssembly_4 hresult();" & _ "DefineDynamicAssembly_5 hresult();" & _ "DefineDynamicAssembly_6 hresult();" & _ "DefineDynamicAssembly_7 hresult();" & _ "DefineDynamicAssembly_8 hresult();" & _ "DefineDynamicAssembly_9 hresult();" & _ "CreateInstance hresult(bstr;bstr;object*);" & _ "CreateInstanceFrom hresult();" & _ "CreateInstance_2 hresult();" & _ "CreateInstanceFrom_2 hresult();" & _ "CreateInstance_3 hresult();" & _ "CreateInstanceFrom_3 hresult();" & _ "Load hresult();" & _ "Load_2 hresult();" & _ "Load_3 hresult();" & _ "Load_4 hresult();" & _ "Load_5 hresult();" & _ "Load_6 hresult();" & _ "Load_7 hresult();" & _ "ExecuteAssembly hresult();" & _ "ExecuteAssembly_2 hresult();" & _ "ExecuteAssembly_3 hresult();" & _ "get_FriendlyName hresult();" & _ "get_BaseDirectory hresult();" & _ "get_RelativeSearchPath hresult();" & _ "get_ShadowCopyFiles hresult();" & _ "GetAssemblies hresult();" & _ "AppendPrivatePath hresult();" & _ "ClearPrivatePath ) = 0; hresult();" & _ "SetShadowCopyPath hresult();" & _ "ClearShadowCopyPath ) = 0; hresult();" & _ "SetCachePath hresult();" & _ "SetData hresult();" & _ "GetData hresult();" & _ "SetAppDomainPolicy hresult();" & _ "SetThreadPrincipal hresult();" & _ "SetPrincipalPolicy hresult();" & _ "DoCallBack hresult();" & _ "get_DynamicDirectory hresult();" Global Const $sTag_ICorRuntimeHost = _ "CreateLogicalThreadState hresult();" & _ "DeleteLogicalThreadState hresult();" & _ "SwitchInLogicalThreadState hresult();" & _ "SwitchOutLogicalThreadState hresult();" & _ "LocksHeldByLogicalThread hresult();" & _ "MapFile hresult();" & _ "GetConfiguration hresult();" & _ "Start hresult();" & _ "Stop hresult();" & _ "CreateDomain hresult();" & _ "GetDefaultDomain hresult(ptr*);" & _ "EnumDomains hresult();" & _ "NextDomain hresult();" & _ "CloseEnum hresult();" & _ "CreateDomainEx hresult();" & _ "CreateDomainSetup hresult();" & _ "CreateEvidence hresult();" & _ "UnloadDomain hresult();" & _ "CurrentDomain hresult();" Global Const $sCLSID_CLRMetaHost = "{9280188d-0e8e-4867-b30c-7fa83884e8de}" Global Const $sIID_ICLRMetaHost = "{d332db9e-b9b3-4125-8207-a14884f53216}" Global Const $sIID_ICLRRuntimeInfo = "{BD39D1D2-BA2F-486a-89B0-B4B0CB466891}" Global Const $sCLSID_CLRRuntimeHost = "{90F1A06E-7712-4762-86B5-7A5EBA6BDB02}" Global Const $sIID_ICLRRuntimeHost = "{90F1A06C-7712-4762-86B5-7A5EBA6BDB02}" Global $tCLSID_CLRMetaHost = _WinAPI_CLSIDFromString($sCLSID_CLRMetaHost) Global $tIID_ICLRMetaHost = _WinAPI_CLSIDFromString($sIID_ICLRMetaHost) Global $tIID_ICLRRuntimeInfo = _WinAPI_CLSIDFromString($sIID_ICLRRuntimeInfo) Global $tCLSID_CLRRuntimeHost = _WinAPI_CLSIDFromString($sCLSID_CLRRuntimeHost) Global $tIID_ICLRRuntimeHost = _WinAPI_CLSIDFromString($sIID_ICLRRuntimeHost) Global Const $sCLSID_CorRuntimeHost = "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}" Global Const $sIID_ICorRuntimeHost = "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}" Global $tCLSID_CorRuntimeHost = _WinAPI_CLSIDFromString($sCLSID_CorRuntimeHost) Global $tIID_ICorRuntimeHost = _WinAPI_CLSIDFromString($sIID_ICorRuntimeHost) Local $hMSCorEE = DllOpen("MSCorEE.DLL") Local $aRet = DllCall($hMSCorEE, "long", "CLRCreateInstance", "struct*", $tCLSID_CLRMetaHost, "struct*", $tIID_ICLRMetaHost, "ptr*", 0) If $aRet[0] = $S_OK Then Local $pClrHost = $aRet[3] Local $oClrHost = ObjCreateInterface($pClrHost, $sIID_ICLRMetaHost, $sTag_CLRMetaHost) ConsoleWrite(">oClrHost: " & IsObj($oClrHost) & @CRLF) Local $sNETFrameworkVersion = "v4.0.30319" Local $tCLRRuntimeInfo = DllStructCreate("ptr") $oClrHost.GetRuntime($sNETFrameworkVersion, $tIID_ICLRRuntimeInfo, DllStructGetPtr($tCLRRuntimeInfo)) Local $pCLRRuntimeInfo = DllStructGetData($tCLRRuntimeInfo, 1) ConsoleWrite(">pCLRRuntimeInfo: " & $pCLRRuntimeInfo & @CRLF) Local $oCLRRuntimeInfo = ObjCreateInterface($pCLRRuntimeInfo, $sIID_ICLRRuntimeInfo, $sTag_CLRRuntimeInfo) ConsoleWrite(">oCLRRuntimeInfo: " & IsObj($oCLRRuntimeInfo) & @CRLF) Local $isIsLoadable = 0 $oCLRRuntimeInfo.IsLoadable($isIsLoadable) ConsoleWrite(">IsLoadable: " & $isIsLoadable & @CRLF) If $isIsLoadable Then Local $tCLRRuntimeHost = DllStructCreate("ptr") $oCLRRuntimeInfo.GetInterface(DllStructGetPtr($tCLSID_CLRRuntimeHost), DllStructGetPtr($tIID_ICLRRuntimeHost), DllStructGetPtr($tCLRRuntimeHost)) Local $pCLRRuntimeHost = DllStructGetData($tCLRRuntimeHost, 1) ConsoleWrite(">pCLRRuntimeHost: " & $pCLRRuntimeHost & @CRLF) Local $oCLRRuntimeHost = ObjCreateInterface($pCLRRuntimeHost, $sIID_ICLRRuntimeHost, $sTag_CLRRuntimeHost) ConsoleWrite(">oCLRRuntimeHost: " & IsObj($oCLRRuntimeHost) & @CRLF) Local $iRet = 0 $oCLRRuntimeHost.Start() ;$oCLRRuntimeHost.ExecuteInDefaultAppDomain(@ScriptDir & "\C#Library.dll", "ClassLibraryDemo.ClassDemo", "NetMsgBox", "AutoIt Rocks!!! " & @CRLF & "Danyfirex does too lol!!!", $iRet) ;ConsoleWrite(">Ret: " & $iRet & @CRLF) Local $tCorRuntimeHost = DllStructCreate("ptr") $oCLRRuntimeInfo.GetInterface(DllStructGetPtr($tCLSID_CorRuntimeHost), DllStructGetPtr($tIID_ICorRuntimeHost), DllStructGetPtr($tCorRuntimeHost)) Local $pCorRuntimeHost = DllStructGetData($tCorRuntimeHost, 1) ;~ ConsoleWrite("$pCorRuntimeHost = " & $pCorRuntimeHost & @CRLF) Local $oCorRuntimeHost = ObjCreateInterface($pCorRuntimeHost, $sIID_ICorRuntimeHost, $sTag_ICorRuntimeHost) ConsoleWrite("IsObj( $oCorRuntimeHost ) = " & IsObj($oCorRuntimeHost) & @CRLF) $oCorRuntimeHost.Start() Local $pAppDomain = 0 $oCorRuntimeHost.GetDefaultDomain($pAppDomain) ConsoleWrite("$pAppDomain = " & Ptr($pAppDomain) & @CRLF) Local $oAppDomain = ObjCreateInterface($pAppDomain, $sIID_AppDomain, $sTag_AppDomain) ConsoleWrite("IsObj( $oAppDomain ) = " & IsObj($oAppDomain) & @CRLF) Local $oObject = 0 $oAppDomain.CreateInstance("mscorlib", "System.Collections.Stack", $oObject) ConsoleWrite("IsObj($oObject): " & IsObj($oObject) & @CRLF) Local $oStack = $oObject.Unwrap If IsObj($oStack) Then ConsoleWrite("IsObj($oStack): " & IsObj($oStack) & @CRLF) $oStack.Push("+Bye Bye!!! ^.^") $oStack.Push("+I'm a Stack Object!!!") $oStack.Push("+AutoIt Rocks!!!") ConsoleWrite($oStack.Pop & @CRLF) ConsoleWrite($oStack.Pop & @CRLF) ConsoleWrite($oStack.Pop & @CRLF) $oStack = 0 EndIf EndIf EndIf DllClose($hMSCorEE) ;free Func _WinAPI_CLSIDFromString($sGUID) $tGUID = DllStructCreate('ulong Data1;ushort Data2;ushort Data3;byte Data4[8]') $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 Updated. Saludos1 point
-
fopetesl, You cannot "escape" the GUI and keep the script running if there is no script to run. Clicking the [X] sends a $GUI_EVENT_CLOSE message and looking at your snippets: Case $GUI_EVENT_CLOSE Exit ; You specifically ask the script to end Case $GUI_EVENT_CLOSE ExitLoop ; But once the loop is ended there is no further script to run What you need to do is just delete the GUI: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData(-1, "Energy Star|myNoSleep") GUISetState() $sCurrCombo = "" $nBegin = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Case $hCombo If GUICtrlRead($hCombo) <> $sCurrCombo Then $sCurrCombo = GUICtrlRead($hCombo) MsgBox(0, "Choice", $sCurrCombo) EndIf EndSwitch ; Just to prove the script is still running If TimerDiff($nBegin) > 1000 Then ConsoleWrite("Script running at " & @SEC & @CRLF) $nBegin = TimerInit() EndIf WEnd M231 point