Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/25/2017 in all areas

  1. chillerhippie, How about this virtual keyboard script from my snippets folder: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> $MA_NOACTIVATE = 3 $MA_NOACTIVATEANDEAT = 4 HotKeySet("{ESC}", "On_Exit") Global $aKeys[48] = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", _ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "[", "]", _ "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "'", '"', _ "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "spc", "enter"] ; Create "keyboard" GUI $hGUI = GUICreate("Test", 360, 120, 500, 100, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) $cStart = GUICtrlCreateDummy() + 1 $iCount = 0 For $j = 0 To 3 For $i = 0 To 11 GUICtrlCreateButton($aKeys[$iCount], $i * 30, $j * 30, 30, 30) $iCount += 1 Next Next $cEnd = GUICtrlCreateDummy() - 1 GUISetState() GUIRegisterMsg($WM_MOUSEACTIVATE, "_WM_MOUSEACTIVATE") Run("notepad.exe") While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $cStart To $cEnd Local $sText = ControlGetText($hGUI, "", $iMsg) ; Write key If $sText = "spc" Then Send("{SPACE}") ElseIf $sText = "enter" Then Send("{ENTER}") Else Send($sText) EndIf EndSwitch WEnd Func _WM_MOUSEACTIVATE($hWndGUI, $iMsg, $WParam, $LParam) Switch $hWndGUI Case $hGUI Switch $iMsg Case $WM_MOUSEACTIVATE ; Check mouse position Local $aMouse_Pos = GUIGetCursorInfo($hGUI) If $aMouse_Pos[4] <> 0 Then _SendMessage($hGUI, $WM_COMMAND, _WinAPI_MakeLong($aMouse_Pos[4], $BN_CLICKED), GUICtrlGetHandle($aMouse_Pos[4])) EndIf Return $MA_NOACTIVATEANDEAT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func On_Exit() Exit EndFunc I believe it was wraithdu who produced this version, although a number of us worked together to get there. M23
    1 point
  2. #include <GUIConstants.au3> #include <WinAPI.au3> #include <WinAPISys.au3> Global Const $WA_ACTIVE = 1 Global Const $WA_CLICKACTIVE = 2 Global $hMain = GUICreate("Window 1") Global $hSecond = GUICreate("Window 2") GUIRegisterMsg($WM_ACTIVATE, WM_ACTIVATE) GUISetState(@SW_SHOW, $hMain) GUISetState(@SW_SHOW, $hSecond) While (True) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE Exit 0 EndSwitch WEnd Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam) Switch (_WinAPI_LoWord($wParam)) Case $WA_ACTIVE, $WA_CLICKACTIVE Switch ($hWnd) Case $hSecond ConsoleWrite("[" & @MIN & ":" & @SEC & ":" & @MSEC & "] Second window set to active, changing to main" & @LF) Return _WinAPI_SetActiveWindow($hMain) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_ACTIVATE Give that a go instead of using AdLibRegister. Just use GUIRegisterMsg($WM_ACTIVATE, "") to turn off the activate function
    1 point
  3. Jos

    AutoIt Error Line 0

    Ah ok... well try to figure out which exe is causing this issue and you can PM it to me to investigate. Jos
    1 point
  4. what kind of data are contained in the array "$ g_aSIDEItem" ?
    1 point
  5. See the Ping function in the help.
    1 point
  6. The second AutoHotkey example (C-sharp code) 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(bstr;variant*);" & _ "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() ; tst01.ahk ; CLR_LoadLibrary ; assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 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] := "System" 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( "System" ) ) SafeArrayUnaccessData( $pSafeArray ) Local $pAsmProvider $oAssemblyType.InvokeMember_3( "LoadWithPartialName", 0x158, 0, 0, $pSafeArray, $pAsmProvider ) ; 0x158 = $BindingFlags_Static + $BindingFlags_Public + $BindingFlags_FlattenHierarchy + $BindingFlags_InvokeMethod ConsoleWrite( "$pAsmProvider = " & Ptr( $pAsmProvider ) & @CRLF ) Local $oAsmProvider = ObjCreateInterface( $pAsmProvider, $sIID_IAssembly, $sTag_IAssembly ) ConsoleWrite( "IsObj( $oAsmProvider ) = " & IsObj( $oAsmProvider ) & @CRLF ) ; codeProvider := asmProvider.CreateInstance("Microsoft.CSharp.CSharpCodeProvider") Local $oCodeProvider $oAsmProvider.CreateInstance( "Microsoft.CSharp.CSharpCodeProvider", $oCodeProvider ) ConsoleWrite( "IsObj( $oCodeProvider ) = " & IsObj( $oCodeProvider ) & @CRLF ) ; codeCompiler := codeProvider.CreateCompiler() Local $oCodeCompiler = $oCodeProvider.CreateCompiler() ConsoleWrite( "IsObj( $oCodeCompiler ) = " & IsObj( $oCodeCompiler ) & @CRLF ) Local $oAsmSystem = $oAsmProvider ; Convert | delimited list of references into an array. ; References = "System.dll | System.Management.dll | System.Windows.Forms.dll" ; StringSplit, Refs, References, |, %A_Space%%A_Tab% ; aRefs := ComObjArray(8, Refs0) ; Loop % Refs0 ; aRefs[A_Index-1] := Refs%A_Index% Local $tSafeArray1Bound = DllStructCreate( $tagSAFEARRAYBOUND ) Local $pSafeArray1, $pSafeArray1Data DllStructSetData( $tSafeArray1Bound, "cElements", 3 ) DllStructSetData( $tSafeArray1Bound, "lLbound", 0 ) $pSafeArray1 = SafeArrayCreate( $VT_BSTR, 1, $tSafeArray1Bound ) SafeArrayAccessData( $pSafeArray1, $pSafeArray1Data ) DllStructSetData( DllStructCreate( "ptr", $pSafeArray1Data ), 1, SysAllocString( "System.dll" ) ) $pSafeArray1Data += @AutoItX64 ? 8 : 4 DllStructSetData( DllStructCreate( "ptr", $pSafeArray1Data ), 1, SysAllocString( "System.Management.dll" ) ) $pSafeArray1Data += @AutoItX64 ? 8 : 4 DllStructSetData( DllStructCreate( "ptr", $pSafeArray1Data ), 1, SysAllocString( "System.Windows.Forms.dll" ) ) SafeArrayUnaccessData( $pSafeArray1 ) ; prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs) ; args := ComObjArray(0xC, 1), args[0] := "XPTable.dll" Local $tSafeArray2Bound = DllStructCreate( $tagSAFEARRAYBOUND ) Local $pSafeArray2, $pSafeArray2Data DllStructSetData( $tSafeArray2Bound, "cElements", 1 ) DllStructSetData( $tSafeArray2Bound, "lLbound", 0 ) $pSafeArray2 = SafeArrayCreate( $VT_VARIANT, 1, $tSafeArray2Bound ) SafeArrayAccessData( $pSafeArray2, $pSafeArray2Data ) DllStructSetData( DllStructCreate( "word", $pSafeArray2Data ), 1, $VT_BSTR + $VT_ARRAY ) DllStructSetData( DllStructCreate( "ptr", $pSafeArray2Data + 8 ), 1, $pSafeArray1 ) SafeArrayUnaccessData( $pSafeArray2 ) ; 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 ) Local $oPrms $oAsmSystem.CreateInstance_3( "System.CodeDom.Compiler.CompilerParameters", True, 0, 0, $pSafeArray2, 0, $pSAEmpty, $oPrms ) ConsoleWrite( "IsObj( $oPrms ) = " & IsObj( $oPrms ) & @CRLF ) Local $sCode = FileRead( "Code.cs" ) ConsoleWrite( "$sCode = " & @CRLF & $sCode ) ; Compile! ; compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code) Local $oCompilerRes = $oCodeCompiler.CompileAssemblyFromSource( $oPrms, $sCode ) ConsoleWrite( "IsObj( $oCompilerRes ) = " & IsObj( $oCompilerRes ) & @CRLF ) Local $pCodeAssembly = $oCompilerRes.CompiledAssembly() ConsoleWrite( "$pCodeAssembly = " & Ptr( $pCodeAssembly ) & @CRLF ) Local $oCodeAssembly = ObjCreateInterface( $pCodeAssembly, $sIID_IAssembly, $sTag_IAssembly ) ConsoleWrite( "IsObj( $oCodeAssembly ) = " & IsObj( $oCodeAssembly ) & @CRLF ) Local $oCodeObject $oCodeAssembly.CreateInstance_2( "Foo", True, $oCodeObject ) ConsoleWrite( "IsObj( $oCodeObject ) = " & IsObj( $oCodeObject ) & @CRLF ) Local $sKram = $oCodeObject.Test( "Win32_Processor" ) $sKram = StringReplace( $sKram, "/n", @CRLF ) MsgBox( 0, "", $sKram ) EndIf EndIf DllClose($hMSCorEE) EndFunc Since you need Variant and SafeArray UDFs I've included all code in the zip. Run tst01.au3 in SciTE. Output in SciTE: >oClrHost: 1 >pCLRRuntimeInfo: 0x008F9980 >oCLRRuntimeInfo: 1 >IsLoadable: True >pCLRRuntimeHost: 0x0088C768 >oCLRRuntimeHost: 1 IsObj( $oCorRuntimeHost ) = 1 $pAppDomain = 0x006D002C IsObj( $oAppDomain ) = 1 $pType = 0x006D0018 IsObj( $oType ) = 1 $pAssembly = 0x006DFFD0 IsObj( $oAssembly ) = 1 $pAssemblyType = 0x006DFF98 IsObj( $oAssemblyType ) = 1 $pAsmProvider = 0x006DFF50 IsObj( $oAsmProvider ) = 1 IsObj( $oCodeProvider ) = 1 IsObj( $oCodeCompiler ) = 1 IsObj( $oPrms ) = 1 $sCode = using System.Windows.Forms; using System.Management; using System; class Foo { public string Test(string geraet) { string Tabelle = " "; ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from " + geraet); ManagementObjectCollection irgendwas = searcher.Get(); foreach (ManagementObject mo in irgendwas) { foreach (PropertyData prop in mo.Properties) { Tabelle = Tabelle + "/n" + prop.Name + ": " + prop.Value; } } return Tabelle; } } IsObj( $oCompilerRes ) = 1 $pCodeAssembly = 0x006DFE90 IsObj( $oCodeAssembly ) = 1 IsObj( $oCodeObject ) = 1 CScode.7z
    1 point
  7. AnonymousX, A better solution is to set the correct style for the MsgBox like this: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) local $but = GUICtrlCreateButton("Hello", 150,150,85,25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) MsgBox($MB_TOPMOST + $MB_TASKMODAL,"Message","Try hitting the hello button several times,without closing this window. Now close this window and see how script wasn't restricted it just was waiting and storing the instructions") WinWaitClose("Message") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK Exit case $but MsgBox(0,"","Hello") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example All is explained in the Modal MsgBox Styles tutorial in the Wiki. M23
    1 point
  8. jchd

    virtual ListView sqlite

    I only have pretty little time to dig into this but here are what strikes me. You shouldn't open / close the DB at every SQL statement. Open it at program start and close it at program termination. Test and handle SQLite error codes, not only SQLITE_OK. Use a large SQLite cache. It won't make a diference first time but subsequent requests will run much faster. You don't have to convert AutoIt (UTF16-LE) strings back and forth to/from UTF8. Use UTF16 SQLite primitives instead. I understand the sample DB is only a toy but its schema lives me with questions about replicated columns. You select * which is very bad. If ever your DB design changes for some good reasons someday, changing the order of columns, you'll have to change many things in the code. Select named columns and only those which are useful for the task at hand. Your app design seems to load the whole DB in a huge listview, say with 180K rows, and let the user painfully navigate in this ocean. It's way more efficient and user-friendly to let the user select the criterions he needs for what he wants to view/change and, from that, build a query to select and load, in a manageable listview, only what he actually needs. Create indices for speeding up the various specific queries mentionned above. I have only little insight about the actual goals, but if you're dealing with automotive parts, you might find it useful and efficient to create columns (and indices) for manufacturer (car brand), item familly and create separate tables with foreign keys from there to ease queries. Generic items (light bulbs, tyres, accessories, ...) can populate a "Generic" brand.
    1 point
×
×
  • Create New...