Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/01/2021 in all areas

  1. yes, most likely that will not work anymore This comes closest I think but not sure if that was fully finished But you can also look at the webdriver concept https://github.com/Danp2/WebDriver/releases/tag/0.4.1.2
    1 point
  2. You need to do something like this. Local $tFunctions = DllStructCreate("ptr[" $iNumberOfFunctions "]", $pModule) DllCallAddress("none", DllStructGetData($tFunctions,1, 4)) ;GetModuleHandle Saludos
    1 point
  3. 1 point
  4. Struct ArrayIn Example03 above, many instances of a larger structure are copied from .NET to AutoIt. The total time spent both generating and copying data is measured. In order to measure the time used exclusively for copying data, it's necessary to split the code into two functions: A function to generate data and a function to copy data. This can be done by storing all instances of the structure in an array of structures. To copy instances of the structure from AutoIt back to .NET, it's convenient to store the structures in an array in the .NET code. Example03 below is a new version where it's possible to measure structure generation times and transfer times separately. Similarly, Example02 is a new version where it's possible to measure array generation times and transfer times separately. Note that code to generate duplicates is included in Rand2dArrayCreate() and RandStructsCreate() functions. Example02 #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <Array.au3> #include "Random2dArray.au3" Example( 100, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 50000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 100000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 250000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 750000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 2000000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Func Example( _ $iRows, _ ; Number of rows in the array $aColumns, _ ; Number of columns and data types in the array, see 1) in docu $sSource = "" ) ; Character source for string columns, random strings are created from these characters ; Load .NET code, create object Local Static $oNetCode = 0, $oRand2dArrayClass If Not $oNetCode Then $oNetCode = DotNet_LoadVBcode( FileRead( "Example02.vb" ), "System.dll" ) $oRand2dArrayClass = DotNet_CreateObject( $oNetCode, "Rand2dArrayClass" ) EndIf ; Check $aColumns array Local $iError = CheckColumnsArray( $aColumns ) If $iError Then Return SetError($iError,0,0) ; Define $aColTypes array Local $iColumns = UBound( $aColumns ) Local $aColTypes[6][$iColumns+1] ; Update $aColTypes and $aColumns For $i = 0 To $iColumns - 1 If CalcColTypes( $i, $aColumns, $aColTypes, $iRows, $sSource ) Then ContinueLoop $aColumns[$i][2] += 1 ; Because of .NET Random class ; Convert duplicates as a percentage to number of unique rows $aColumns[$i][3] = $iRows - Int( $iRows * $aColumns[$i][3] / 100 ) If $aColumns[$i][3] And $aColumns[$i][3] < $iRows Then $aColumns[$i][3] -= 1 Next ; Visual code verification If $iRows = 100 Then $oRand2dArrayClass.Rand2dArrayCreate( $iRows, $aColumns, $aColTypes, $sSource ) Local $aArray100 = $oRand2dArrayClass.Rand2dArrayToAutoIt() $oRand2dArrayClass.Rand2dArrayDelete() _ArrayDisplay( $aArray100 ) Return EndIf ; Number of rows ConsoleWrite( "Array rows = " & $iRows & @CRLF ) ; Create array Local $hTimer = TimerInit() $oRand2dArrayClass.Rand2dArrayCreate( $iRows, $aColumns, $aColTypes, $sSource ) ConsoleWrite( "Create array = " & TimerDiff( $hTimer ) & @CRLF ) ; Pass array to AutoIt $hTimer = TimerInit() Local $aArray = $oRand2dArrayClass.Rand2dArrayToAutoIt() ConsoleWrite( "Pass to AutoIt = " & TimerDiff( $hTimer ) & @CRLF ) ; Delete .NET array $oRand2dArrayClass.Rand2dArrayDelete() ; Pass array to .NET $hTimer = TimerInit() $oRand2dArrayClass.Rand2dArrayToDotNet( $aArray ) ConsoleWrite( "Pass to .NET = " & TimerDiff( $hTimer ) & @CRLF & @CRLF ) ; Delete .NET array $oRand2dArrayClass.Rand2dArrayDelete() EndFunc #cs Array rows = 50000 Create array = 161.3358744048 Pass to AutoIt = 53.1796500402687 Pass to .NET = 128.998994597868 Array rows = 100000 Create array = 276.623278397762 Pass to AutoIt = 108.432993923537 Pass to .NET = 258.063372194661 Array rows = 250000 Create array = 898.781576733183 Pass to AutoIt = 264.890631696736 Pass to .NET = 631.123803539603 Array rows = 750000 Create array = 2717.34763337093 Pass to AutoIt = 837.568960363219 Pass to .NET = 2094.36373615079 Array rows = 2000000 Create array = 7424.69637769875 Pass to AutoIt = 2081.94096635518 Pass to .NET = 5806.68962274841 #ce Imports System Class Rand2dArrayClass 'Global in class Dim aObjects(,) Public Sub Rand2dArrayCreate( iRows As Integer, aColumns As Object(,), aColTypes As Object(,), sSource As String ) Dim iColumns As Integer = aColumns.GetUpperBound(1) + 1 Dim aSource As Char() = sSource.ToCharArray() Dim iSourceLen As Integer = sSource.Length ReDim aObjects(iColumns-1,iRows-1) Dim oRnd As New Random() Dim sStr As String = "" Dim k, y, m, dMax As Integer For i As Integer = 0 To iRows - 1 'String columns For j As Integer = 1 To aColTypes(0,0) k = aColTypes(j,0) If i <= aColumns(3,k) Then For l As Integer = 1 To oRnd.Next( aColumns(1,k), aColumns(2,k) ) sStr &= aSource(oRnd.Next( iSourceLen )) Next aObjects(k,i) = sStr sStr = "" Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Integer columns For j As Integer = 1 To aColTypes(0,1) k = aColTypes(j,1) If i <= aColumns(3,k) Then aObjects(k,i) = oRnd.Next( aColumns(1,k), aColumns(2,k) ) Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Float columns For j As Integer = 1 To aColTypes(0,2) k = aColTypes(j,2) If i <= aColumns(3,k) Then aObjects(k,i) = aColumns(1,k) + ( aColumns(2,k) - aColumns(1,k) ) * oRnd.NextDouble() Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Date columns For j As Integer = 1 To aColTypes(0,3) k = aColTypes(j,3) If i <= aColumns(3,k) Then y = oRnd.Next( aColumns(1,k), aColumns(2,k) ) m = oRnd.Next( 1, 13 ) Select m Case 1, 3, 5, 7, 8, 10, 12 dMax = 31 Case 4, 6, 9, 11 dMax = 30 Case Else '2 dMax = If( y Mod 4 <> 0, 28, If( y Mod 400 = 0, 29, If( y Mod 100 = 0, 28, 29 ) ) ) End Select aObjects(k,i) = y * 10000 + m * 100 + oRnd.Next( 1, dMax + 1 ) Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Time columns For j As Integer = 1 To aColTypes(0,4) k = aColTypes(j,4) If i <= aColumns(3,k) Then aObjects(k,i) = oRnd.Next( aColumns(1,k), aColumns(2,k) ) * 10000 + oRnd.Next( 0, 60 ) * 100 + oRnd.Next( 0, 60 ) Else aObjects(k,i) = aObjects(k,oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Row/col columns For j As Integer = 1 To aColTypes(0,5) k = aColTypes(j,5) aObjects(k,i) = i & "/" & k Next Next End Sub Public Function Rand2dArrayToAutoIt() As Object(,) Return aObjects End Function Public Sub Rand2dArrayToDotNet( aArray As Object(,) ) aObjects = aArray End Sub Public Sub Rand2dArrayDelete() ReDim aObjects(0,0) End Sub End Class Example03 #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include "Random2dArray.au3" Example( 100, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 50000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 100000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Example( 250000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 750000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) ;Example( 2000000, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) Func Example( _ $iRows, _ ; Number of rows in the array $aColumns, _ ; Number of columns and data types in the array, see 1) in docu $sSource = "" ) ; Character source for string columns, random strings are created from these characters ; Load .NET code, create object Local Static $oNetCode = 0, $oRandStructsClass If Not $oNetCode Then $oNetCode = DotNet_LoadVBcode( FileRead( "Example03.vb" ), "System.dll" ) $oRandStructsClass = DotNet_CreateObject( $oNetCode, "RandStructsClass" ) EndIf ; Check $aColumns array Local $iError = CheckColumnsArray( $aColumns ) If $iError Then Return SetError($iError,0,0) ; Define $aColTypes array Local $iColumns = UBound( $aColumns ) Local $aColTypes[6][$iColumns+1] ; Update $aColTypes and $aColumns For $i = 0 To $iColumns - 1 If CalcColTypes( $i, $aColumns, $aColTypes, $iRows, $sSource ) Then ContinueLoop $aColumns[$i][2] += 1 ; Because of .NET Random class ; Convert duplicates as a percentage to number of unique rows $aColumns[$i][3] = $iRows - Int( $iRows * $aColumns[$i][3] / 100 ) If $aColumns[$i][3] And $aColumns[$i][3] < $iRows Then $aColumns[$i][3] -= 1 Next ; Visual code verification If $iRows = 100 Then $oRandStructsClass.RandStructsCreate( $iRows, $aColumns, $aColTypes, $sSource ) Local $pPtr100 = $oRandStructsClass.RandStructsToAutoIt( $iRows ), $tStruct, $tString, $iSize = @AutoItX64 ? 56 : 40 ConsoleWrite( "$pPtr100 = " & Ptr( $pPtr100 ) & @CRLF & @CRLF ) ; Display first structure ConsoleWrite( "First structure:" & @CRLF ) $tStruct = DllStructCreate( "int iString;ptr pString;int iInteger;double dDouble;int iDate;int iTime;int iRowCol;ptr pRowCol", $pPtr100 ) ConsoleWrite( "$tStruct.iString = " & $tStruct.iString & @CRLF ) ConsoleWrite( "$tStruct.pString = " & Ptr( $tStruct.pString ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iString & "]", $tStruct.pString ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF ) ConsoleWrite( "$tStruct.iInteger = " & $tStruct.iInteger & @CRLF ) ConsoleWrite( "$tStruct.dDouble = " & $tStruct.dDouble & @CRLF ) ConsoleWrite( "$tStruct.iDate = " & $tStruct.iDate & @CRLF ) ConsoleWrite( "$tStruct.iTime = " & $tStruct.iTime & @CRLF ) ConsoleWrite( "$tStruct.iRowCol = " & $tStruct.iRowCol & @CRLF ) ConsoleWrite( "$tStruct.pRowCol = " & Ptr( $tStruct.pRowCol ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iRowCol & "]", $tStruct.pRowCol ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF & @CRLF ) ; Display last structure ConsoleWrite( "Last structure:" & @CRLF ) $tStruct = DllStructCreate( "int iString;ptr pString;int iInteger;double dDouble;int iDate;int iTime;int iRowCol;ptr pRowCol", $pPtr100 + $iSize * ( $iRows - 1 ) ) ConsoleWrite( "$tStruct.iString = " & $tStruct.iString & @CRLF ) ConsoleWrite( "$tStruct.pString = " & Ptr( $tStruct.pString ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iString & "]", $tStruct.pString ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF ) ConsoleWrite( "$tStruct.iInteger = " & $tStruct.iInteger & @CRLF ) ConsoleWrite( "$tStruct.dDouble = " & $tStruct.dDouble & @CRLF ) ConsoleWrite( "$tStruct.iDate = " & $tStruct.iDate & @CRLF ) ConsoleWrite( "$tStruct.iTime = " & $tStruct.iTime & @CRLF ) ConsoleWrite( "$tStruct.iRowCol = " & $tStruct.iRowCol & @CRLF ) ConsoleWrite( "$tStruct.pRowCol = " & Ptr( $tStruct.pRowCol ) & @CRLF ) $tString = DllStructCreate( "char sString[" & $tStruct.iRowCol & "]", $tStruct.pRowCol ) ConsoleWrite( "$tString.sString = " & $tString.sString & @CRLF & @CRLF ) ; Delete .NET structs $oRandStructsClass.RandStructsDelete() ; Free structure memory $oRandStructsClass.FreeStructure() Return EndIf ; Number of rows ConsoleWrite( "Struct rows = " & $iRows & @CRLF ) ; Create structs Local $hTimer = TimerInit() $oRandStructsClass.RandStructsCreate( $iRows, $aColumns, $aColTypes, $sSource ) ConsoleWrite( "Create structs = " & TimerDiff( $hTimer ) & @CRLF ) ; Copy structs to AutoIt $hTimer = TimerInit() Local $pPtr = $oRandStructsClass.RandStructsToAutoIt( $iRows ) ConsoleWrite( "Copy to AutoIt = " & TimerDiff( $hTimer ) & @CRLF ) ; Delete .NET structs $oRandStructsClass.RandStructsDelete() ; Copy structs to .NET $hTimer = TimerInit() $oRandStructsClass.RandStructsToDotNet( $iRows ) ConsoleWrite( "Copy to .NET = " & TimerDiff( $hTimer ) & @CRLF & @CRLF ) ; Delete .NET structs $oRandStructsClass.RandStructsDelete() ; Free structure memory $oRandStructsClass.FreeStructure() #forceref $pPtr EndFunc #cs Struct rows = 50000 Create structs = 118.687319937022 Copy to AutoIt = 14.4374527116075 Copy to .NET = 27.3954765492515 Struct rows = 100000 Create structs = 270.28500615459 Copy to AutoIt = 30.5258261460518 Copy to .NET = 71.3821661221316 Struct rows = 250000 Create structs = 654.394887271121 Copy to AutoIt = 70.4205373540553 Copy to .NET = 144.230739927763 Struct rows = 750000 Create structs = 1731.17973924928 Copy to AutoIt = 203.711537966051 Copy to .NET = 437.325547215529 Struct rows = 2000000 Create structs = 4556.50490192412 Copy to AutoIt = 547.36291803216 Copy to .NET = 1646.96449730863 #ce Imports System Imports System.Runtime.InteropServices Public Structure Test Public iString As Integer 'String length Public sString As String Public iInteger As Integer Public dDouble As Double Public iDate As Integer Public iTime As Integer Public iRowCol As Integer 'String length Public sRowCol As String End Structure Class RandStructsClass 'Globals in class Dim tTest As Test, iSize As Integer = Marshal.SizeOf( tTest ) Dim aTest() As Test Dim pnt As IntPtr Public Sub RandStructsCreate( iRows As Integer, aColumns As Object(,), aColTypes As Object(,), sSource As String ) Dim iColumns As Integer = aColumns.GetUpperBound(1) + 1 Dim aSource As Char() = sSource.ToCharArray() Dim iSourceLen As Integer = sSource.Length Dim oRnd As New Random() ReDim aTest(iRows-1) Dim tTest As Test Dim sStr As String = "" Dim k, y, m, dMax As Integer For i As Integer = 0 To iRows - 1 'String columns For j As Integer = 1 To aColTypes(0,0) k = aColTypes(j,0) If i <= aColumns(3,k) Then For l As Integer = 1 To oRnd.Next( aColumns(1,k), aColumns(2,k) ) sStr &= aSource(oRnd.Next( iSourceLen )) Next tTest.iString = sStr.Length + 1 tTest.sString = sStr sStr = "" Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Integer columns For j As Integer = 1 To aColTypes(0,1) k = aColTypes(j,1) If i <= aColumns(3,k) Then tTest.iInteger = oRnd.Next( aColumns(1,k), aColumns(2,k) ) Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Float columns For j As Integer = 1 To aColTypes(0,2) k = aColTypes(j,2) If i <= aColumns(3,k) Then tTest.dDouble = aColumns(1,k) + ( aColumns(2,k) - aColumns(1,k) ) * oRnd.NextDouble() Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Date columns For j As Integer = 1 To aColTypes(0,3) k = aColTypes(j,3) If i <= aColumns(3,k) Then y = oRnd.Next( aColumns(1,k), aColumns(2,k) ) m = oRnd.Next( 1, 13 ) Select m Case 1, 3, 5, 7, 8, 10, 12 dMax = 31 Case 4, 6, 9, 11 dMax = 30 Case Else '2 dMax = If( y Mod 4 <> 0, 28, If( y Mod 400 = 0, 29, If( y Mod 100 = 0, 28, 29 ) ) ) End Select tTest.iDate = y * 10000 + m * 100 + oRnd.Next( 1, dMax + 1 ) Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Time columns For j As Integer = 1 To aColTypes(0,4) k = aColTypes(j,4) If i <= aColumns(3,k) Then tTest.iTime = oRnd.Next( aColumns(1,k), aColumns(2,k) ) * 10000 + oRnd.Next( 0, 60 ) * 100 + oRnd.Next( 0, 60 ) Else aTest(i) = aTest(oRnd.Next(0,aColumns(3,k)+1)) End If Next 'Row/col columns For j As Integer = 1 To aColTypes(0,5) k = aColTypes(j,5) tTest.sRowCol = i & "/" & k tTest.iRowCol = tTest.sRowCol.Length + 1 Next aTest(i) = tTest Next End Sub Public Function RandStructsToAutoIt( iRows As Integer ) As String pnt = Marshal.AllocHGlobal( iRows * iSize ) 'Console.WriteLine( "Marshal.SizeOf( tTest ) = {0}", iSize ) 'Copy structures to unmanaged memory For i As Integer = 0 To iRows - 1 Marshal.StructureToPtr( aTest(i), pnt + i * iSize, False ) Next Return pnt.ToString() End Function Public Sub RandStructsToDotNet( iRows As Integer ) ReDim aTest(iRows-1) For i As Integer = 0 To iRows - 1 aTest(i) = CType( Marshal.PtrToStructure( pnt + i * iSize, GetType( Test ) ), Test ) Next End Sub Public Sub RandStructsDelete() ReDim aTest(0) End Sub Public Sub FreeStructure() Marshal.FreeHGlobal( pnt ) End Sub End Class Performance Example02 Example03 --------------------------------- --------------------------------- Array rows = 50000 Struct rows = 50000 Create array = 161.3358744048 Create structs = 118.687319937022 Pass to AutoIt = 53.1796500402687 Copy to AutoIt = 14.4374527116075 Pass to .NET = 128.998994597868 Copy to .NET = 27.3954765492515 Array rows = 100000 Struct rows = 100000 Create array = 276.623278397762 Create structs = 270.28500615459 Pass to AutoIt = 108.432993923537 Copy to AutoIt = 30.5258261460518 Pass to .NET = 258.063372194661 Copy to .NET = 71.3821661221316 Array rows = 250000 Struct rows = 250000 Create array = 898.781576733183 Create structs = 654.394887271121 Pass to AutoIt = 264.890631696736 Copy to AutoIt = 70.4205373540553 Pass to .NET = 631.123803539603 Copy to .NET = 144.230739927763 Array rows = 750000 Struct rows = 750000 Create array = 2717.34763337093 Create structs = 1731.17973924928 Pass to AutoIt = 837.568960363219 Copy to AutoIt = 203.711537966051 Pass to .NET = 2094.36373615079 Copy to .NET = 437.325547215529 Array rows = 2000000 Struct rows = 2000000 Create array = 7424.69637769875 Create structs = 4556.50490192412 Pass to AutoIt = 2081.94096635518 Copy to AutoIt = 547.36291803216 Pass to .NET = 5806.68962274841 Copy to .NET = 1646.96449730863 Data creation rates are higher for structures than for arrays. It takes about 30 - 100 percent longer to create arrays than structures. This is probably due to the fact that the 2d arrays are arrays of objects, where the more computationally heavy objects are needed to handle data of different types (strings, integers and doubles). While the 1d array of structures consists only of one data type (structures). The code to create random data is the same for both arrays and structures. Therefore, it can almost only be the difference between arrays and structures that results in a higher speed for structures. Data transfer rates are significantly higher for structures than for arrays. The speeds are about 3-4 times higher for structures. And this applies to transfers in both directions from .NET to AutoIt and from AutoIt to .NET. Transfers from .NET to AutoIt are 2-3 times faster than the other direction. With the Marshal Class used in this thread, it's apparently not possible to transfer a 1d array of structures as a single data block. But it cannot be ruled out that it's possible through custom marshalling. And that, of course, would be very interesting. 7z-fileNew 7z-file at bottom of first post.
    1 point
  5. Trash, Test 3 within the Example_1 script does show how to display an & character: Case $hButton3 ; Set the message box right justification, colours (yellow text on blue background) and change font _ExtMsgBoxSet(1, 2, 0x004080, 0xFFFF00, 10, "Comic Sans MS") $sMsg = "This is centred on 'EMB Test' with an Exclamation icon, 2 buttons, wrapped right justified coloured text, " $sMsg &= "coloured background, no Taskbar button and TOPMOST set" & @CRLF & @CRLF $sMsg &= "Note you can get && in button text" & @CRLF $sMsg &= "and neither button is set as default" & @CRLF & @CRLF $sMsg &= "It will not time out" ; Use $MB_ constant $iRetValue = _ExtMsgBox($EMB_ICONEXCLAM, "One Way|To && Fro", "Test 3", $sMsg, 0, $hTest_GUI) ConsoleWrite("Test 3 returned: " & $iRetValue & @CRLF) ; Reset to default _ExtMsgBoxSet(Default) Specifically this line: "Note you can get && in button text" So I did my best to explain! Glad you got it sorted. M23
    1 point
×
×
  • Create New...