Leaderboard
Popular Content
Showing content with the highest reputation on 03/26/2018 in all areas
-
Func _CertUtil_Example_Dump() Local $sFile1 = 'C:\1\cert.txt' Local $sFile2 = 'C:\1\cert2.cer' Local $sXML_File = FileOpenDialog('Choose XML File', @ScriptDir, 'XML Files (*.xml)') If @error Then Return SetError(@error, @extended, 0) ConsoleWrite("! $sXML_File = " & $sXML_File & @CRLF) Local $hFile = FileOpen($sXML_File, $FO_READ + $FO_UTF8_NOBOM) Local $sFileContent = FileRead($hFile) FileClose($hFile) Local $aX509Certificate = _StringBetween($sFileContent, '<X509Certificate>', '</X509Certificate>') If @error Then MsgBox($MB_ICONERROR, '_StringBetween', '@error = ' & @error & @CRLF & '@extended = ' & @extended) Local $sX509Certificate = $aX509Certificate[0] Local $hFile = FileOpen($sFile1, $FO_OVERWRITE + $FO_CREATEPATH + $FO_BINARY ) FileWrite($hFile, '-----BEGIN CERTIFICATE-----' & @CRLF & $sX509Certificate & @CRLF & '-----END CERTIFICATE-----') FileClose($hFile) _CertUtil_ConvertToBinary($sFile1, $sFile2) If @error Then MsgBox($MB_ICONERROR, '_CertUtil_ConvertToBinary', '@error = ' & @error & @CRLF & '@extended = ' & @extended) Local $sResult = _CertUtil_Dump($sFile2) If @error Then MsgBox($MB_ICONERROR, '_CertUtil_Dump', '@error = ' & @error & @CRLF & '@extended = ' & @extended) MsgBox(0, '$sResult', $sResult) ClipPut($sResult) EndFunc ;==>_Example Result:2 points
-
Version 1.15.4
863 downloads
cDebug.au3 includes four main debugging UDFs: _GuiDebug(), _ConsDebug(), _ClipDebug() and _FormatValsForDebug(). They all dump the values of all AutoIt subtypes and expressions, in a structured manner, including nested arrays (up to 3 dimensions) and slices of them, and even DLL structs and maps. It is an alternative to a graphical debugger, offering GUI output. The format for calling the UDFs has been designed to make coding a call as convenient and fast as possible, minimizing coding effort and the chances of errors: the $name argument is often the same as the variables arguments, enclosed in quote marks. For DLL structures, if you specify a tag, cDebug checks for differences between it and what it detects. If you only specify a structure variable, it can report the structure it detects, with the values of elements. It does much more than MsgBox(), ConsoleWrite() and _ArrayDisplay(), in a definitely user-friendly manner, and does its best to avoid hiding your code in SciTE. #include cDebug no maps.au3 or cDebug.au3 at the top of your script. If you #include cDebug.au3 (the version with maps) #include #AutoIt3Wrapper_Version=B before #include cDebug.au3 It is fully documented in . During debugging and development of new features, the current version is used to debug the upcoming version, so there is much testing, even so bugs are always possible, particularly in new features, such as reporting elements of maps whose keys match a regular expression. Bug reports and suggestions are welcome. These UDFs have been in regular use for some years. Because when cDebug was developed, maps were a use at your own risk feature, there are two streams of cDebug: cDebug.au3 reports maps, so to use it you must be running a version of AutoIt that supports maps, e.g. 3.3.15.0, and #include cDebug.au3 cDebug no maps.au3 does not report maps, so you can be running any recent version of AutoIt, e.g. 3.3.14.5, and #include cDebug no maps.au3 The only difference between the two streams is that map-reporting code is commented out in cDebug no maps.au3 . These functions are documented in cDebug.pdf A teaser This script: #AutoIt3Wrapper_Version=B ; beta 3.3.15.0 or greater is mandatory for cDebug.au3 #include "cDebug.au3" Local $seasons[] $seasons.summer = 'May to September' $seasons.spring = 'April' $seasons.fall = 'October to November' $seasons.winter = 'December to March' Local $aCats[3][3] = [['jack','black',3],['suki','grey',4],[$seasons,'','']] Local $i = 1 Local $tStruct = DllStructCreate('uint') DllStructSetData($tStruct,1,2018) _GuiDebug('At line '&@ScriptLineNumber,'$cats,jack is,$cats[..][$i],$i,hex,structure{uint}', _ $aCats,$aCats[0][2],$aCats,$i,Hex(-$i),$tstruct) produces: Acknowledgements Melba23, Kafu, ProgAndy, jchd1 point -
Fast Array Management Functions UDF
kurtykurtyboy reacted to LarsJ for a topic
With the functions in Accessing AutoIt Arrays it's possible to create some fast array management functions where all the hard work is done by compiled code or by accessing array memory directly. This is the main UDF for a number of sub-UDFs. The sub-UDFs divided by topics (general functions, sorting functions, etc.) implements the actual array functions and will be published as new examples. The main UDF contains functions to access arrays, functions and utilities common to several sub-UDFs, and functions to display arrays. The display functions are copied from Data display functions based on virtual listviews. Large arrays Arrays of interest are large arrays with 100,000 - 1,000,000 elements. The numbers are very round numbers. Depending on the specific array and situation, it may be 10,000 or 200,000 instead of 100,000 elements. And it may be 500,000 or 10,000,000 instead of 1,000,000 elements. Data types Array data types are primarily simple data types such as integers, floats and strings. Array elements containing arrays (arrays of arrays), functions, objects, structures (DllStructs) or maps (in the beta version) are not supported. The techniques to access AutoIt arrays from compiled code and to access array memory directly are both based on passing arrays as parameters to methods of COM objects. The arrays are passed by value. What happens if a special data type eg. a DllStruct contained in an array element is passed to compiled VB code? Is it still the same DllStruct when the array gets back to AutoIt? Such issues have not been taken into account in this first version. As far as arrays of arrays are concerned and the embedded arrays also contains simple data types there are no problems. This allows for new versions of some of the functions with support for embedded arrays. Maybe also support for other data types. Structure The project is structured this way: FAMproj\ - Top folder Display\ - Data display functions FAMudf\ - Fast Array Management Functions UDF FASudf\ - Fast Array Sorting and Management Functions UDF FGAudf\ - Fast General Array Management Functions UDF FXXudf\ - More fast array management functions UDFs The name of the top folder, FAMproj, is only used in 7z-files. It's not used in any UDFs or scripts. You can rename FAMproj as you want. But the other folders cannot be renamed. These names are used in UDFs and scripts. Main UDF The main UDF, FAMudf, and FAMudf.7z below is organized this way: FAMproj\ - Top folder Display\ - Data display functions FAMudf\ - Fast Array Management Functions UDF AccArrays\ - Access AutoIt arrays from compiled code Utilities\ - Contains utility functions common to all UDFs Readme.txt - Folder list (this list) and usage instructions Sub-UDFs Sub-UDFs, FXXudf's, and corresponding FXXudf.7z files are organized this way: FAMproj\ - Top folder FXXudf\ - Fast Array Management Functions sub-UDF DLLFiles\ - C++ DLL-files and VB.NET assembly DLL-files Examples\ - Example scripts to demonstrate the functions HelpFiles\ - Detailed information about some of the functions Functions.txt - Function list and headers (the main help file) Use_of_UDF.txt - Explains how to use the UDF in your own project Includes\ - Files that you include in your own AutoIt scripts Resources\ - Resources used in examples and runtime measuring Runtimes\ - Compare runtimes for AutoIt code and optimized code Sources\ - Contains C++ source files and VB.NET source files Utilities\ - Utility functions to generate VB.NET DLL-files Readme.txt - Folder list (this list) and usage instructions Not all sub-folders are used in all sub-UDFs. Note that the top folder FAMproj\ is the same folder for all UDFs. If you unzip the 7z-files in <My folder>, FAMproj will be an immediate subfolder: <My folder>\FAMproj. The structure of FAMproj\ should look as described in the Structure-section above. The name FAMproj is only used in 7z-files. You can rename it as you want. C++ code is delivered both as source files and as 32 and 64 bit dll-files. VB code is only delivered as source files which can be compiled and loaded on the fly. If you want to compile VB code into .NET assembly dll-files you have to do it yourself with the functions (usually only one) in Utilities\. All dll-files are stored in DLLFiles\. So far, the following sub-UDFs are available: Fast Array Sorting and Management Functions UDF Fast General Array Management Functions UDF Fast SQLite Management Functions UDF Information This thread will be used for general information for the entire project. Along the way more posts will be added below. Code optimization especially in relation to array transfer End of first version. Next version? FAMudf.7z FAMudf is delivered in FAMudf.7z and is the main UDF that's used by all the sub-UDFs. It contains functions to access arrays from compiled code and to access array memory directly. It also contains the display functions. FAMudf is a set of helper functions, but it does not contain any array management functions. The sub-UDFs contains the array management functions. To use the array management functions you have to download one or more of the sub-UDFs. You need AutoIt 3.3.10 or later. Tested on Windows 10 and Windows 7. Comments are welcome. Let me know if there are any issues. FAMudf.7z1 point -
Fast Array Sorting and Management Functions UDF
kurtykurtyboy reacted to LarsJ for a topic
FASudf is a sub-UDF of FAMudf, Fast Array Management Functions UDF. FAMudf is needed to use FASudf. FASudf contains functions for sorting arrays and functions that are otherwise related to sorted arrays. In addition to sorting functions, this first version only contains functions to generate arrays of random data. Only 2D arrays are supported. The sorting functions are implemented through index-based binary sorting algorithms. This means that an array is not sorted directly. Instead, an index is created that defines the sorting order of the rows. An array can be sorted by several columns by creating several sorting indexes. Functionality to handle duplicates is included. The functions to generate random arrays does not create completely random data. Elements in a column are of same type: strings, integers or floats. Strings can either be a number of random characters from a source string or they may be row/column strings. Integers can be created as dates and times on the formats yymmdd and hhmmss. One or more empty columns can be included. Random arrays are used to test most of the functions in the sub-UDFs. Both groups of functions are based on code in Using C# and VB Code in AutoIt. Optimizations Optimizations are based on techniques in this post about Optimizing C# and VB code. This is a summary of the techniques: Use pure AutoIt code for small arrays Use compiled code for medium arrays Use multi-threaded code for large arrays Consider data (strings take longer) Limit the number of array transfers Because there are several different factors to consider, code optimization is far from a trivial task. This means that it's not possible to implement all code in a single function. Along the way, it appears that there is a need for a fairly large number of functions. Eg. there are 4 different functions to create random arrays and 3 different functions to sort arrays. Functions This is a list of the most important functions copied from HelpFiles\Functions.txt: ; FAS_SortingInitVbSrc Compile and load .NET code from source file. ; FAS_SortingInitVbDll Load .NET code from .NET assembly DLL file. ; FAS_Random2DArray Creates/returns a 2D array of random data. ; FAS_Random2DArrayCount Returns number of rows to display progress. ; FAS_Random2DArrayGet Returns the 2D array of random data from VB code. ; FAS_Random2DArrayWr Splash text and progress bar for large arrays. ; FAS_Sort2DArray Index based sorting of a 2D array. ; FAS_Sort2DArrayWr Splash text and progress bar for large arrays. ; FAS_Random2DArrayGUI GUI to create 2D arrays of random data. ; FAS_Sort2DArrayGUI GUI to sort a 2D array. FAS_Random2DArray and FAS_Random2DArrayWr are wrapper functions for 4 different functions to create random arrays. FAS_Sort2DArray and FAS_Sort2DArrayWr are wrapper functions for 3 different functions to sort arrays. FAS_Random2DArrayWr and FAS_Sort2DArrayWr are the easy-to-use functions that automatically shows splash texts and progress bars for large arrays. Use FAS_Random2DArray and FAS_Sort2DArray if you want to create your own progress bars. The code Although there are many more functions and much more code, the ideas and methods are the same as in the small Delete UDF that is used as an example in Accessing AutoIt Arrays. Examples This version does not contain examples for all functions. Only for the functions in the list above. Examples for other functions will be added in later posts. This is the example for FAS_Random2DArrayWr: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "..\..\..\FASudf\Includes\SortingWr.au3" FAS_SortingInitVbSrc( "..\..\..\FASudf\Sources\Sorting.vb" ) #include "..\..\..\Display\Display.au3" Opt( "MustDeclareVars", 1 ) Example( 50 ) ; Small Example( 50000 ) ; Medium Example( 500000 ) ; Large Example( 1000000 ) ; XL array Example( 2000000 ) ; XXL array Func Example( $iRows ) Local $aArray, $aCols = "sifdtr" Local $sSource = "TheQuickBrownFoxJumpsOverTheLazyDog" Local $aDisplay = Display_GetRandom2DArrayFeatures( $aCols ) $aArray = FAS_Random2DArrayWr( $iRows, $aCols, $sSource, 1 ) ; $bRetArray = 1 _ArrayDisplayEx( $aArray, $iRows & " rows", $aDisplay[1], 0, $aDisplay[0] ) EndFunc Runtimes Runtimes for random arrays: Code executed as 32 bit code Code executed as 64 bit code ============================ ============================ 100 rows, 6 columns 100 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 4.1606 Pure AutoIt code: 4.1559 Compiled VB code: 17.8798 Compiled VB code: 25.5180 Multi-threaded code: 71.1700 Multi-threaded code: 88.3572 500 rows, 6 columns 500 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 58.1467 Pure AutoIt code: 62.0461 Compiled VB code: 2.7133 Compiled VB code: 6.1394 Multi-threaded code: 58.8299 Multi-threaded code: 67.1078 1,000 rows, 6 columns 1,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 91.9293 Pure AutoIt code: 65.2808 Compiled VB code: 4.9111 Compiled VB code: 5.0884 Multi-threaded code: 60.2677 Multi-threaded code: 5.8344 2,000 rows, 6 columns 2,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 128.4206 Pure AutoIt code: 78.8515 Compiled VB code: 8.5295 Compiled VB code: 9.0436 Multi-threaded code: 60.2874 Multi-threaded code: 76.0251 5,000 rows, 6 columns 5,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 208.8182 Pure AutoIt code: 216.4811 Compiled VB code: 23.7436 Compiled VB code: 22.5961 Multi-threaded code: 106.6686 Multi-threaded code: 18.0873 10,000 rows, 6 columns 10,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 437.9269 Pure AutoIt code: 361.5627 Compiled VB code: 47.4749 Compiled VB code: 42.8944 Multi-threaded code: 125.4751 Multi-threaded code: 146.5746 20,000 rows, 6 columns 20,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 831.8726 Pure AutoIt code: 745.0602 Compiled VB code: 96.0985 Compiled VB code: 102.5241 Multi-threaded code: 174.3039 Multi-threaded code: 164.1153 50,000 rows, 6 columns 50,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 2026.3799 Pure AutoIt code: 1827.4788 Compiled VB code: 272.8744 Compiled VB code: 227.1584 Multi-threaded code: 232.7363 Multi-threaded code: 284.4890 100,000 rows, 6 columns 100,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 4093.4503 Pure AutoIt code: 3651.6002 Compiled VB code: 523.6434 Compiled VB code: 432.8995 Multi-threaded code: 494.8062 Multi-threaded code: 448.7902 250,000 rows, 6 columns 250,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 10148.1931 Pure AutoIt code: 9047.4262 Compiled VB code: 1339.1534 Compiled VB code: 1159.0255 Multi-threaded code: 1163.8851 Multi-threaded code: 1216.2328 500,000 rows, 6 columns 500,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 20467.1356 Pure AutoIt code: 18071.1545 Compiled VB code: 2758.6908 Compiled VB code: 2558.2818 Multi-threaded code: 2408.5988 Multi-threaded code: 2503.3011 750,000 rows, 6 columns 750,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 30603.0113 Pure AutoIt code: 27007.7100 Compiled VB code: 4054.2868 Compiled VB code: 3890.3879 Multi-threaded code: 3484.5627 Multi-threaded code: 3304.3183 1,000,000 rows, 6 columns 1,000,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 41063.6182 Pure AutoIt code: 36056.7854 Compiled VB code: 5559.1431 Compiled VB code: 5490.3201 Multi-threaded code: 4888.2765 Multi-threaded code: 4406.3113 2,000,000 rows, 6 columns 2,000,000 rows, 6 columns Generate array with random data Generate array with random data ----------------------------------- ----------------------------------- Pure AutoIt code: 82056.5640 Pure AutoIt code: 71932.1727 Compiled VB code: 10980.5317 Compiled VB code: 10904.8085 Multi-threaded code: 9855.7511 Multi-threaded code: 9487.6442 Runtimes for sorting arrays. Includes runtimes for _ArraySort: Code executed as 32 bit code Code executed as 64 bit code ============================ ============================ 100 rows, 6 columns 100 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 3.7835 Pure AutoIt code: 3.0832 Compiled VB code: 10.6970 Compiled VB code: 11.6062 Multi-threaded code: 74.7990 Multi-threaded code: 80.2156 _ArraySort, pure AutoIt: 21.4189 _ArraySort, pure AutoIt: 19.0863 500 rows, 6 columns 500 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 41.2535 Pure AutoIt code: 29.6888 Compiled VB code: 2.9862 Compiled VB code: 2.2933 Multi-threaded code: 64.8079 Multi-threaded code: 59.0133 _ArraySort, pure AutoIt: 70.4841 _ArraySort, pure AutoIt: 56.6128 1,000 rows, 6 columns 1,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 43.8856 Pure AutoIt code: 64.8200 Compiled VB code: 6.1015 Compiled VB code: 6.0453 Multi-threaded code: 65.3971 Multi-threaded code: 71.4382 _ArraySort, pure AutoIt: 110.7674 _ArraySort, pure AutoIt: 72.7744 2,000 rows, 6 columns 2,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 91.4105 Pure AutoIt code: 71.4255 Compiled VB code: 11.6514 Compiled VB code: 11.3633 Multi-threaded code: 75.2001 Multi-threaded code: 76.5462 _ArraySort, pure AutoIt: 143.6646 _ArraySort, pure AutoIt: 135.8939 5,000 rows, 6 columns 5,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 246.0873 Pure AutoIt code: 198.8700 Compiled VB code: 28.9558 Compiled VB code: 26.9486 Multi-threaded code: 99.0564 Multi-threaded code: 107.8676 _ArraySort, pure AutoIt: 331.9612 _ArraySort, pure AutoIt: 288.6266 10,000 rows, 6 columns 10,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 542.8726 Pure AutoIt code: 432.4651 Compiled VB code: 75.7265 Compiled VB code: 59.6339 Multi-threaded code: 150.3806 Multi-threaded code: 123.7613 _ArraySort, pure AutoIt: 694.8603 _ArraySort, pure AutoIt: 602.0131 20,000 rows, 6 columns 20,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 1219.0863 Pure AutoIt code: 940.2462 Compiled VB code: 171.3294 Compiled VB code: 159.0582 Multi-threaded code: 216.6440 Multi-threaded code: 175.9055 _ArraySort, pure AutoIt: 1460.1318 _ArraySort, pure AutoIt: 1256.1998 50,000 rows, 6 columns 50,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 3738.0328 Pure AutoIt code: 2661.5985 Compiled VB code: 549.0830 Compiled VB code: 472.7786 Multi-threaded code: 321.4487 Multi-threaded code: 310.9871 _ArraySort, pure AutoIt: 3965.3475 _ArraySort, pure AutoIt: 3418.2730 100,000 rows, 6 columns 100,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 9359.8104 Pure AutoIt code: 5911.9112 Compiled VB code: 1524.1232 Compiled VB code: 1161.3261 Multi-threaded code: 809.8367 Multi-threaded code: 648.4087 _ArraySort, pure AutoIt: 8379.1084 _ArraySort, pure AutoIt: 7261.7838 250,000 rows, 6 columns 250,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 35442.6676 Pure AutoIt code: 18072.7239 Compiled VB code: 7033.7629 Compiled VB code: 4992.7779 Multi-threaded code: 2169.2635 Multi-threaded code: 1714.5306 _ArraySort, pure AutoIt: 22453.6015 _ArraySort, pure AutoIt: 19454.1581 500,000 rows, 6 columns 500,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 108605.2420 Pure AutoIt code: 44026.5583 Compiled VB code: 24606.1316 Compiled VB code: 16528.1968 Multi-threaded code: 5590.5327 Multi-threaded code: 4385.4038 _ArraySort, pure AutoIt: 47146.5217 _ArraySort, pure AutoIt: 41167.9802 750,000 rows, 6 columns 750,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 219284.6336 Pure AutoIt code: 78915.0445 Compiled VB code: 53395.0051 Compiled VB code: 34612.3167 Multi-threaded code: 10383.0850 Multi-threaded code: 7705.0778 _ArraySort, pure AutoIt: 72782.3310 _ArraySort, pure AutoIt: 64061.6790 1,000,000 rows, 6 columns 1,000,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 367550.2873 Pure AutoIt code: 123784.3113 Compiled VB code: 94398.9554 Compiled VB code: 61403.6193 Multi-threaded code: 16732.9943 Multi-threaded code: 11891.9866 _ArraySort, pure AutoIt: 99281.2820 _ArraySort, pure AutoIt: 85971.6482 2,000,000 rows, 6 columns 2,000,000 rows, 6 columns Sort array by column 0, strings Sort array by column 0, strings ------------------------------------- ------------------------------------- Pure AutoIt code: 1347477.8241 Pure AutoIt code: 415035.5839 Compiled VB code: 402581.6253 Compiled VB code: 280823.8333 Multi-threaded code: 60879.4978 Multi-threaded code: 49133.9863 _ArraySort, pure AutoIt: 268274.5685 _ArraySort, pure AutoIt: 178115.1385 GUI-functions The GUIs in "Examples\4) GUI functions" looks like this: If you run RandomArrayGUI.au3 and clicks "Create array" and "Create code", code is created and saved in RandomArrayCode.au3. The code is immediately executable: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "..\..\..\FASudf\Includes\SortingWr.au3" ; Path? FAS_SortingInitVbSrc( "..\..\..\FASudf\Sources\Sorting.vb" ) ; Path? #include "..\..\..\Display\Display.au3" ; Path? Opt( "MustDeclareVars", 1 ) RandomArray( 100000 ) ;Global $aArray = RandomArray( 100000 ) Func RandomArray( $iRows ) ; --- Create array --- Local $sSource = "TheQuickBrownFoxJumpsOverTheLazyDog" Local $aColumns = [ [ "Strings", 16, 32, 0 ], _ [ "Integers", 0, 99999, 0 ], _ [ "Floats", 0, 99999, 0 ], _ [ "Dates", 2010, 2020, 0 ], _ [ "Times", 0, 23, 0 ], _ [ "Row/Col" ] ] Local $aArray = FAS_Random2DArrayWr( $iRows, $aColumns, $sSource, 1 ) ; $bRetArray = 1 ; --- Display array --- Local $aDisplay = Display_GetRandom2DArrayFeatures( $aColumns ) _ArrayDisplayEx( $aArray, "", $aDisplay[1], 0, $aDisplay[0] ) ; $sHeader, $aFeatures ; --- Del/Ret array --- If IsArray( $aArray ) Then $aArray = 0 ;If IsArray( $aArray ) Then Return $aArray EndFunc If you run SortingArrayGUI.au3, deletes all rows (uncheck checkboxes) except "Dates" and "Times" and clicks "Sort array" and "Create code", code is created and saved in SortingArrayCode.au3. The file is copied and renamed to SortingArrayCode-a.au3. This code is not immediately executable: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "..\..\..\FASudf\Includes\SortingWr.au3" ; Path? FAS_SortingInitVbSrc( "..\..\..\FASudf\Sources\Sorting.vb" ) ; Path? #include "..\..\..\Display\Display.au3" ; Path? Opt( "MustDeclareVars", 1 ) ;SortArray( $aArray ) Func SortArray( $aArray ) ; --- Sort array --- Local $aCompare = [ [ 3, 0, 0 ], _ [ 4, 0, 0 ] ] Local $aSortIndex = FAS_Sort2DArrayWr( $aArray, $aCompare, 1, 1, 1 ) ; $bDelArray = 1, $bSortByIndex = 1, $bDuplicates = 1 ; --- Display array --- Local $aColumns = [ "Strings", "Integers", "Floats", "Dates", "Times", "Row/Col" ] Local $aDisplay = Display_GetRandom2DArrayFeatures( $aColumns ) $aDisplay = Display_GetSort2DArrayFeaturesEx( $aDisplay, $aCompare, $aSortIndex, "Grey", UBound( $aColumns ) ) _ArrayDisplayEx( $aArray, "", $aDisplay[1], 0, $aDisplay[0] ) ; $sHeader, $aFeatures ; --- Duplicates --- Local $iDupls = FAS_Sort2DDuplsCount() If $iDupls > 0 Then $aDisplay = Display_GetSort2DArrayDuplicates( $aDisplay, $iDupls ) _ArrayDisplayEx( $aArray, $aDisplay[2], $aDisplay[1], 0, $aDisplay[0] ) ; $sTitle, $sHeader, $aFeatures EndIf ; --- Delete index --- If IsArray( $aSortIndex ) Or IsDllStruct( $aSortIndex ) Then $aSortIndex = 0 EndFunc To make the code executable copy the contents of RandomArrayCode.au3 to the top of SortingArrayCode.au3 in this way: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "..\..\..\FASudf\Includes\SortingWr.au3" ; Path? FAS_SortingInitVbSrc( "..\..\..\FASudf\Sources\Sorting.vb" ) ; Path? #include "..\..\..\Display\Display.au3" ; Path? Opt( "MustDeclareVars", 1 ) ;RandomArray( 100000 ) Global $aArray = RandomArray( 100000 ) Func RandomArray( $iRows ) ; --- Create array --- Local $sSource = "TheQuickBrownFoxJumpsOverTheLazyDog" Local $aColumns = [ [ "Strings", 16, 32, 0 ], _ [ "Integers", 0, 99999, 0 ], _ [ "Floats", 0, 99999, 0 ], _ [ "Dates", 2010, 2020, 0 ], _ [ "Times", 0, 23, 0 ], _ [ "Row/Col" ] ] Local $aArray = FAS_Random2DArrayWr( $iRows, $aColumns, $sSource, 1 ) ; $bRetArray = 1 ; --- Display array --- Local $aDisplay = Display_GetRandom2DArrayFeatures( $aColumns ) _ArrayDisplayEx( $aArray, "", $aDisplay[1], 0, $aDisplay[0] ) ; $sHeader, $aFeatures ; --- Del/Ret array --- ;If IsArray( $aArray ) Then $aArray = 0 If IsArray( $aArray ) Then Return $aArray EndFunc SortArray( $aArray ) Func SortArray( $aArray ) ; --- Sort array --- Local $aCompare = [ [ 3, 0, 0 ], _ [ 4, 0, 0 ] ] Local $aSortIndex = FAS_Sort2DArrayWr( $aArray, $aCompare, 1, 1, 1 ) ; $bDelArray = 1, $bSortByIndex = 1, $bDuplicates = 1 ; --- Display array --- Local $aColumns = [ "Strings", "Integers", "Floats", "Dates", "Times", "Row/Col" ] Local $aDisplay = Display_GetRandom2DArrayFeatures( $aColumns ) $aDisplay = Display_GetSort2DArrayFeaturesEx( $aDisplay, $aCompare, $aSortIndex, "Grey", UBound( $aColumns ) ) _ArrayDisplayEx( $aArray, "", $aDisplay[1], 0, $aDisplay[0] ) ; $sHeader, $aFeatures ; --- Duplicates --- Local $iDupls = FAS_Sort2DDuplsCount() If $iDupls > 0 Then $aDisplay = Display_GetSort2DArrayDuplicates( $aDisplay, $iDupls ) _ArrayDisplayEx( $aArray, $aDisplay[2], $aDisplay[1], 0, $aDisplay[0] ) ; $sTitle, $sHeader, $aFeatures EndIf ; --- Delete index --- If IsArray( $aSortIndex ) Or IsDllStruct( $aSortIndex ) Then $aSortIndex = 0 EndFunc What's next This first version of FASudf is not complete. The sorting functions were initially developed to support virtual listviews but can be used more generally in this version. The sorting functions were also used to find out if the ideas and methods throughout the project works and are durable and stable. Sorting functions are sufficiently complicated to conclude that if these functions works, then other types of functions will probably also work. The random arrays are used to test most of the functions in the entire FAMudf, Fast Array Management Functions UDF. But these two groups of functions are the only ones made so far. Functions like FAS_InsertRows, FAS_DeleteRows, FAS_ModifyRows and FAS_SearchRows to manage sorted arrays are already planned. Eg. to insert a row into a sorted array, it should be sufficient to add the row to the end of the array and then insert the row number at the correct position in the index (or indexes). To delete a row in a sorted array, it should be sufficient to delete the row in the index (or indexes). That way, it should be possible to make some fast functions to manage sorted arrays. FASudf.7z FAMudf.7z must be downloaded and unzipped to use FASudf. FASudf.7z must be unzipped in the same folder structure as FAMudf.7z. See Fast Array Management Functions UDF for details. Start running some of the examples in FAMproj\FASudf\Examples\ (with F5 in SciTE) and look at the code in the examples. You need AutoIt 3.3.10 or later. Tested on Windows 10 and Windows 7. Comments are welcome. Let me know if there are any issues. FASudf.7z1 point -
Look in the help file for the HotKeySet function.1 point
-
Today @tungpheng asked "How to View the Contents of a Certificate" Here is a solution: Download:1 point
-
1 point
-
Click on embedded button link in Chrome
Earthshine reacted to Jos for a topic
@mikes99, Why are you creating a second thread on the same topic? Please stick to one! Jos1 point -
Threads merge and please stick to the one thread!1 point
-
Can not click IE with name or id or class or text
anhoang reacted to Earthshine for a topic
post the whole script. you have given nothing that anyone can help you with. also, you started a new thread for the same issue. does this example code work for you? trying to determine what your issues are is difficult when you don't post your whole script. this is from Help file and it works fine. Does it work for you? then you can use this as your template to get where you need to be. Example 1 from help: ; Open a browser with the "form" example, get a reference ; to the submit button by name and "click" it. This technique ; of submitting forms is useful because many forms rely on JavaScript ; code and "onClick" events on their submit button making _IEFormSubmit() ; not perform as expected #include <IE.au3> Local $oIE = _IE_Example("form") Local $oSubmit = _IEGetObjByName($oIE, "submitExample") _IEAction($oSubmit, "click") _IELoadWait($oIE)1 point -
Look into kiosk mode for windows Kinda depends what version of windows you are using but made for this. http://techgenix.com/windows-kiosk-mode-solutions/1 point
-
I solve your problem .... partialy, I must change my UDF to show entire solution.1 point
-
It looks promising. I will look closer when I get some spare time. Thanks1 point
-
sorry I missed the part about you wanting the microphone as well #include <WinAPICOM.au3> Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(int;int;ptr*);" & _ "GetDefaultAudioEndpoint hresult(int;int;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" Global Const $IID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $tagIMMDevice = "Activate hresult(ptr;dword;variant*;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(ptr*);" & _ "GetState hresult(dword*);" Global Const $IID_IPropertyStore = "{886d8eeb-8cf2-4446-8d02-cdba1dbdcf99}" Global Const $tagIPropertyStore = "GetCount hresult(dword*);" & _ "GetAt hresult(dword;ptr*);" & _ "GetValue hresult(struct*;variant*);" & _ "SetValue hresult(struct*;variant);" & _ "Commit hresult();" Global Const $sPKEY_Device_FriendlyName = "{a45c254e-df1c-4efd-8020-67d146a850e0}, 14" Global Const $sPKEY_Audio_Endpoint_GUID = "{1DA5D803-D492-4EDD-8C23-E0C0FFEE7F0E}, 4" Global Const $STGM_READ = 0 Global Const $DEVICE_STATE_ACTIVE = 0x00000001 Global Const $eRender = 0 Global Const $eCapture = 1 Global Const $eAll = 2 Global Const $EDataFlow_enum_count = 3 Global Const $eConsole = 0 Global Const $eMultimedia = 1 Global Const $eCommunications = 2 Global Const $ERole_enum_count = 3 Func _WinAPI_PKEYFromString($sPKEY, $pID = Default) Local $tPKEY = DllStructCreate("byte GUID[16]; dword PID;") DllCall("propsys.dll", "long", "PSPropertyKeyFromString", "wstr", $sPKEY, "struct*", $tPKEY) If $pID <> Default Then DllStructSetData($tPKEY, "PID", $pID) Return $tPKEY EndFunc ;========================================================== Local $oEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator) Local $pDefaultEndpoint $oEnumerator.GetDefaultAudioEndpoint($eRender, $DEVICE_STATE_ACTIVE, $pDefaultEndpoint) Local $oEndpoint = ObjCreateInterface($pDefaultEndpoint, $IID_IMMDevice, $tagIMMDevice) ; PropertyStore stores properties Local $pProps $oEndpoint.OpenPropertyStore($STGM_READ, $pProps) $oProps = ObjCreateInterface($pProps, $IID_IPropertyStore, $tagIPropertyStore) ; Collect FriendlyName property Local $tPKEY_Device_FriendlyName = _WinAPI_PKEYFromString($sPKEY_Device_FriendlyName) Local $sName $oProps.GetValue($tPKEY_Device_FriendlyName, $sName) ConsoleWrite($sName & @CRLF) Local $tPKEY_Audio_Endpoint_GUID = _WinAPI_PKEYFromString($sPKEY_Audio_Endpoint_GUID) Local $sGuid $oProps.GetValue($tPKEY_Audio_Endpoint_GUID, $sGuid) ConsoleWrite($sGuid & @CRLF) ;------------MICROPHONE $oEnumerator.GetDefaultAudioEndpoint($eCapture, $DEVICE_STATE_ACTIVE, $pDefaultEndpoint) $oEndpoint = ObjCreateInterface($pDefaultEndpoint, $IID_IMMDevice, $tagIMMDevice) ; PropertyStore stores properties $oEndpoint.OpenPropertyStore($STGM_READ, $pProps) $oProps = ObjCreateInterface($pProps, $IID_IPropertyStore, $tagIPropertyStore) ; Collect FriendlyName property $tPKEY_Device_FriendlyName = _WinAPI_PKEYFromString($sPKEY_Device_FriendlyName) $oProps.GetValue($tPKEY_Device_FriendlyName, $sName) ConsoleWrite($sName & @CRLF) $tPKEY_Audio_Endpoint_GUID = _WinAPI_PKEYFromString($sPKEY_Audio_Endpoint_GUID) $oProps.GetValue($tPKEY_Audio_Endpoint_GUID, $sGuid) ConsoleWrite($sGuid & @CRLF)1 point
-
I grabbed that CLSID by searching regedit for 'Manage Wireless Networks' Now what it does with explorer not running IDK but one option would be to kill explorer once you are done with it if it doesn't work how you want1 point
-
An experienced AutoIt user can make the observation that it's possible to pass an array to compiled code as a parameter to a method in a COM object. This also seems to be the only way. An obvious way to process an array in compiled code is therefore simply to create an object and a method to process the array. Another but not quite so obvious way is to replace the methods in an existing object with new methods coded in AutoIt. Inside these methods, you can access an AutoIt array as a pointer to a safearray or as a pointer to the data area in a safearray. And one of these pointers can be passed to compiled code. Note that through a pointer to the data area in a safearray it's possible to access array memory directly. In both of these ways, safarrays plays an important role because COM arrays are safearrays. And you can also conclude that AutoIt arrays are internally stored as safarrays. The first way to create a new object is convenient in programming languages like C# and VB.NET. This way is demonstrated in Using C# and VB Code in AutoIt. Using C# and VB Code in AutoIt is based on DotNet.au3 UDF to access .NET Framework from AutoIt. The advantage of using the latter UDF is that there is no need for an IDE to develop C# or VB code. There is no need other than AutoIt and SciTE. When the code is run in SciTE, C# and VB error messages are displayed in the console. Registering DLL files to access the objects is also not an issue. This is handled through .NET Framework. The other way of replacing the methods in an existing object is convenient in programming languages like assembler, C, C++ and FreeBasic. This way is demonstrated in Accessing AutoIt Variables. When using this way, an IDE is usually needed to develop and compile code. The exception is flat assembler code, that can be handled entirely through AutoIt, SciTE and FASM.DLL. There is a short description and example here. This new project is a common UDF to access AutoIt arrays from compiled code in one of these two ways and to access array memory directly. A small example which implements a Delete.au3 UDF to delete rows and columns demonstrates the usage of the UDF. It's shown how to use Delete.au3 in your own project. Accessing Arrays UDF The zip-file below is structured this way: AccArrays\ - Accessing Arrays UDF Delete\ - Delete example Display\ - Display funcs Project\ - Project example AccArrays\ is further divided into AccArrays\ - 7 files that implements the UDF Utilities\ - Utility functions The 7 files that implements the UDF are copied from Accessing AutoIt Variables and Using C# and VB Code in AutoIt. Some of the files are shortened to only include code necessary for this project. Also, some function and variable names have been changed and shortened. Delete\ and Project\ are discussed below. Display\ contains functions copied from Data display functions. Delete example The Delete example implements 3 functions: DelRowsNum, DeleteRows and DeleteColumns. DelRowsNum demonstrates how to access array memory directly to delete rows in a 1D or 2D array of numbers (no strings). This function is coded entirely in AutoIt. DeleteRows is the general function to delete rows that also can handle arrays containing strings. C++ code is used to performance optimize the function. DeleteColumns deletes columns in a 2D array. The hard work in this function is performed by VB code. Delete\ is divided into 5 main folders: DLLFiles\ - C++ and VB dll-files Examples\ - Function examples Includes\ - Include files Delete.au3 - Main include Functions\ - Implementations DelRowsNum.au3 - Code for DelRowsNum() DeleteRows.au3 - Code for DeleteRows() DeleteColumns.au3 - Code for DeleteColumns() Initialization.au3 - Code to load dll-files Internal\ - Internal files Sources\ - C++ and VB source files Utilities\ - Create .NET assembly dll Before the functions are reviewed, we need to look at a few concepts and topics. Row- and column-major arrays Row- and column-major order of arrays is about how arrays are stored in memory. This is an array with 3 rows and 4 columns $aArray[3][4] = [ [ 1, 2, 3, 4 ], _ [ 5, 6, 7, 8 ], _ [ 9,10,11,12 ] ] If the array is stored in memory as a row-major array it's stored row by row: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 If the array is stored in memory as a column-major array it's stored column by column: 1 | 5 | 9 | 2 | 6 | 10 | 3 | 7 | 11 | 4 | 8 | 12 If array memory can be accessed directly then row manipulations can be performed solely by memory move operations (without any loops) in a row-major array. Column manipulations can be performed solely by memory move operations (without any loops) in a column-major array. This is not important in a conventional AutoIt function because array memory cannot be accessed directly. But it's different for a safearay in an AutoIt object method and for a VB array in a VB object method. When a true AutoIt array is passed to an AutoIt object method as a safearray of variants, this safearray is a row-major array and row manipulations can be performed solely by memory move operations with RtlMoveMemory. When an AutoIt array is passed to a VB object method as an array of objects, this array is a column-major array and column manipulations can be performed solely by memory move operations with Array.Copy and similar methods. Use safearrays to create fast functions to manipulate rows in an array. Use VB arrays to create fast functions to manipulate columns in an array. Problem with safearrays But there is a significant problem with safarrays. Direct memory manipulation of safarrays of variants can only be performed if data in the variants is entirely stored within the variant structure. This generally means that data in the variants and safearrays must be numbers (integers, floats). For strings, only a pointer to the string is stored in the variant. The string itself is stored as a BSTR somewhere else in memory. Direct memory manipulation of safarrays containing strings isn't possible. Elements in a safarray containing strings must be handled ono by one in a loop eg. a C++ loop. Passing arrays to/from methods Another problem is passing arrays back and forth between AutoIt code and object method code. This takes time. For large arrays with more than 1,000,000 elements the time can be significant. Especially passing arrays from AutoIt code to object method code. And particularly arrays containing strings. This topic will be dealed with in more details in a later post. Because it takes a long time to pass an array from AutoIt code to object method code, it's a great advantage to be able to process multiple rows/columns and multiple groups of rows/columns at once. In this way you only need to pass the array once. DelRowsNum DelRowsNum accesses array memory directly and can therefore only handle arrays of numbers (no strings). For arrays of numbers this function is very fast: #include-once #include "Internal\DelFunc.au3" ; Delete one or more rows at the specified (row) indices in a 1D or 2D array that contains numbers only ; DelRowsNum( _ ; ByRef $aArray, _ ; The 1D or 2D array to delete rows in. ; $vIndex ) ; The (row) indices in $aArray where the rows are to be deleted. This can be a single index, a 1D array of indi- ; ; ces or a 2D array of "index/number of rows" pairs. Indices must be in ascending order and cannot be duplicated. ; ; @error: 1 = $aArray is not a 1D or 2D array ; 2 = $vIndex is not a valid specification of $aArray indices/rows ; 3 = Mismatch between $aArray and $vIndex ; Indices plus number of rows in $vIndex must be smaller than number of rows in $aArray, indices ; must be in ascending order, and rows to delete must not overlap (a row must not be deleted twice). Func DelRowsNum( _ ByRef $aArray, _ ; The 1D or 2D array to delete rows in. $vIndex ) ; The (row) indices in $aArray where the rows are to be deleted. ; Check parameters, pass data to method, execute method RowsDelete( $aArray, $vIndex, DelRowsNumMtd ) ; DelFunc.au3 If @error Then Return SetError(@error,0,0) EndFunc Func DelRowsNumMtd( $pvArray ) ; Get data Local $aData AccArrays_PassDataToMethod( 1, $aData ) Local $iRows = $aData[0], $iCols = $aData[1], $aIndex = $aData[2], $iIndex = $aData[3] ; Get safearray Local $psaArrayData Local $psaArray = DllStructGetData( DllStructCreate( "ptr", $pvArray + 8 ), 1 ) SafeArrayAccessData( $psaArray, $psaArrayData ) ; Bytes per row Local $iBytesPrRow = $iCols * ( @AutoItX64 ? 24 : 16 ) ; Delete rows with RtlMoveMemory ; Delete rows by moving existing rows up Local $pCopyTo, $pCopyFrom For $i = $iIndex - 1 To 0 Step -1 $pCopyTo = $psaArrayData + $aIndex[$i][0] * $iBytesPrRow $pCopyFrom = $pCopyTo + $aIndex[$i][1] * $iBytesPrRow DllCall( "kernel32.dll", "none", "RtlMoveMemory", "struct*", $pCopyTo, "struct*", $pCopyFrom, "ulong_ptr", ( $iRows - $aIndex[$i][0] - $aIndex[$i][1] ) * $iBytesPrRow ) $iRows -= $aIndex[$i][1] Next SafeArrayUnaccessData( $psaArray ) ; ReDim safearray to account for deleted rows AccArrays_SafeArrayRedim( $psaArray, $iRows ) EndFunc The purpose of the For-loop in the method code is to delete multiple groups of rows at once. DeleteRows The general function that also can handle arrays containing strings is based on a C++ loop: #include-once #include "Initialization.au3" #include "Internal\DelFunc.au3" ; Delete one or more rows at the specified (row) indices in a 1D or 2D array ; DeleteRows( _ ; ByRef $aArray, _ ; The 1D or 2D array to delete rows in. ; $vIndex ) ; The (row) indices in $aArray where the rows are to be deleted. This can be a single index, a 1D array of indi- ; ; ces or a 2D array of "index/number of rows" pairs. Indices must be in ascending order and cannot be duplicated. ; ; @error: 1 = $aArray is not a 1D or 2D array ; 2 = $vIndex is not a valid specification of $aArray indices/rows ; 3 = Mismatch between $aArray and $vIndex ; Indices plus number of rows in $vIndex must be smaller than number of rows in $aArray, indices ; must be in ascending order, and rows to delete must not overlap (a row must not be deleted twice). ; 4 = C++ code is not initialized Func DeleteRows( _ ByRef $aArray, _ ; The 1D or 2D array to delete rows in. $vIndex ) ; The (row) indices in $aArray where the rows are to be deleted. If Not DeleteInitDll( "IsDeleteInitDll" ) Then Return SetError(4,0,0) ; Check parameters, pass data to method, execute method RowsDelete( $aArray, $vIndex, DeleteRowsMtd ) ; DelFunc.au3 If @error Then Return SetError(@error,0,0) EndFunc Func DeleteRowsMtd( $pvArray, $pvIndex ) ; Get data Local $aData AccArrays_PassDataToMethod( 1, $aData ) Local $iRows = $aData[0], $iCols = $aData[1], $iIndex = $aData[3] ; Get safearrays Local $psaArrayData, $psaIndexData Local $psaArray = DllStructGetData( DllStructCreate( "ptr", $pvArray + 8 ), 1 ) Local $psaIndex = DllStructGetData( DllStructCreate( "ptr", $pvIndex + 8 ), 1 ) SafeArrayAccessData( $psaArray, $psaArrayData ) SafeArrayAccessData( $psaIndex, $psaIndexData ) ; Delete rows through C++ loop ; Delete rows by moving existing rows up $iRows = DllCall( DeleteInitDll(), "int", "DeleteRows", "int", $iRows, "int", $iCols, "int", $iIndex, "ptr", $psaArrayData, "ptr", $psaIndexData )[0] SafeArrayUnaccessData( $psaArray ) SafeArrayUnaccessData( $psaIndex ) ; ReDim safearray to account for deleted rows AccArrays_SafeArrayRedim( $psaArray, $iRows ) EndFunc Sources\Cpp\Delete.cpp: #include <Windows.h> #include <OleAuto.h> int __stdcall DeleteRows( int iRows, int iCols, int iIndex, VARIANT *psaArray, VARIANT *psaIndex ) { int iArrayIdx, iDelRows; int iMoveTo, iMoveFrom, iMoveCnt; for ( int i = iIndex - 1; i >= 0; i-- ) { iArrayIdx = psaIndex[2*i+0].intVal; iDelRows = psaIndex[2*i+1].intVal; // Move existing rows up iMoveTo = iArrayIdx * iCols; iMoveFrom = iMoveTo + iDelRows * iCols; iMoveCnt = ( iRows - iArrayIdx - iDelRows ) * iCols; for ( int j = 0; j < iMoveCnt; j++, VariantCopy( &psaArray[iMoveTo++], &psaArray[iMoveFrom++] ) ); iRows -= iDelRows; } return iRows; } DeleteColumns This function is based on VB code: #include-once #include "Initialization.au3" ; Delete one or more columns at the specified (column) indices in a 2D array ; DeleteColumns( _ ; ByRef $aArray, _ ; The 2D array to delete columns in. ; $vIndex ) ; The (column) indices in $aArray where the columns are to be deleted. This can be a single index, a 1D array of indi- ; ; ces or a 2D array of "index/number of columns" pairs. Indices must be in ascending order and cannot be duplicated. ; ; @error: 1 = $aArray is not a 2D array ; 2 = $vIndex is not a valid specification of $aArray indices/columns ; 3 = Mismatch between $aArray and $vIndex ; Indices plus number of columns in $vIndex must be smaller than number of columns in $aArray, indices ; must be in ascending order, and columns to delete must not overlap (a column must not be deleted twice). ; 4 = VB-code is not initialized ; 5 = No valid VB class object Func DeleteColumns( _ ByRef $aArray, _ ; The 2D array to delete columns in. $vIndex ) ; The (column) indices in $aArray where the columns are to be deleted. ; Check array dimensions Local $aI = [ $vIndex ], $aIndex = IsArray( $vIndex ) ? $vIndex : $aI If Not ( IsArray( $aArray ) And UBound( $aArray, 0 ) = 2 ) Then Return SetError(1,0,0) If Not ( UBound( $aIndex, 0 ) = 1 Or ( UBound( $aIndex, 0 ) = 2 And UBound( $aIndex, 2 ) = 2 ) ) Then Return SetError(2,0,0) ; Indices plus columns in $vIndex must be smaller than columns in $aArray, indices must be in ; ascending order, and columns to delete must not overlap (a column must not be deleted twice). Local $iCols = UBound( $aArray, 2 ), $iIndex = UBound( $aIndex ) If UBound( $aIndex, 0 ) = 1 Then ; 1D array ; Make the 1D array into a 2D array of "index/number of columns" pairs Local $aIndexTmp[$iIndex][2] For $i = 0 To $iIndex - 1 $aIndexTmp[$i][0] = $aIndex[$i] ; $aIndexTmp[$i][0] is the index in $aArray where the columns are to be deleted $aIndexTmp[$i][1] = 1 ; $aIndexTmp[$i][1] is the number of columns to delete in $aArray at the position given by the index Next $aIndex = $aIndexTmp ; $aIndex = $aIndexTmp EndIf Local $iAllCols = $iCols, $j = $iIndex - 1 ; Check that index do not exceed $iCols If $aIndex[$j][0] >= $iCols Then Return SetError(3,0,0) ; Indices in $aIndex must be in ascending order ; Check $aIndex for valid indices and row numbers ; This means that it's enough to check the last index If $aIndex[$j][1] < 1 Or $aIndex[$j][0] + $aIndex[$j][1] > $iCols Then Return SetError(3,0,0) If $iCols - $aIndex[$j][1] < 1 Then Return SetError(3,0,0) $iCols -= $aIndex[$j][1] For $i = $iIndex - 2 To 0 Step -1 If $aIndex[$i][0] > $aIndex[$i+1][0] Or $aIndex[$i][1] < 1 Or $aIndex[$i][0] + $aIndex[$i][1] > $iCols Or _ $aIndex[$i][0] + $aIndex[$i][1] > $aIndex[$i+1][0] Then Return SetError(3,0,0) If $iCols - $aIndex[$i][1] < 1 Then Return SetError(3,0,0) $iCols -= $aIndex[$i][1] Next ; Convert $aIndex to an index of columns that are not deleted ; These columns can be copied into a new array ReDim $aIndex[$iIndex+1][5] $aIndex[0][2] = 0 ; $aIndex[$i][2] is the index in $aArray where from the columns are to be copied $aIndex[0][3] = 0 ; $aIndex[$i][3] is the index in the new array where the columns are to be inserted $aIndex[0][4] = $aIndex[0][0] ; $aIndex[$i][4] is the number of columns to copy For $i = 1 To $iIndex - 1 $aIndex[$i][2] = $aIndex[$i-1][0] + $aIndex[$i-1][1] $aIndex[$i][3] = $aIndex[$i-1][3] + $aIndex[$i-1][4] $aIndex[$i][4] = $aIndex[$i][0] - $aIndex[$i][2] Next $aIndex[$i][2] = $aIndex[$i-1][0] + $aIndex[$i-1][1] $aIndex[$i][3] = $aIndex[$i-1][3] + $aIndex[$i-1][4] $aIndex[$i][4] = $iAllCols - $aIndex[$i][2] If Not DeleteInitVbSrc( "IsDeleteInitVbSrc" ) And _ Not DeleteInitVbDll( "IsDeleteInitVbDll" ) Then Return SetError(4,0,0) Local $oDeleteClass = DeleteInit() If Not IsObj( $oDeleteClass ) Then Return SetError(5,0,0) $aArray = $oDeleteClass.DeleteColumns( $aArray, $aIndex, $iCols ) EndFunc Sources\Delete.vb: Imports System Class DeleteClass Public Function DeleteColumns( aArray As Object(,), aIndex As Object(,), iCols As Integer ) As Object(,) Dim iRows As Integer = aArray.GetUpperBound(1) + 1 Dim aNewArray(iCols-1,iRows-1) As Object For i As Integer = 0 To aIndex.GetUpperBound(1) Array.Copy( aArray, aIndex(2,i) * iRows, aNewArray, aIndex(3,i) * iRows, aIndex(4,i) * iRows ) Next Return aNewArray End Function End Class Initialization Because DeleteRows and DeleteColumns are optimized with compiled code it's necessary to do some initialization to load the compiled code into the AutoIt process. This is done with the functions in Initialization.au3. DeleteRows is optimized with C++ code which is compiled into dll-files and stored in DLLFiles\ as Delete.dll and Delete_x64.dll. Delete.dll and Delete_x64.dll is delivered in the zip-file. DeleteInitDll() in Initialization.au3 loads the dll-files: ; Load compiled code from C++ DLL file ; The DLL file must be specified with a full path ; Or it must be specified with a path relative to the running script ; Or it must be placed in the same folder as the running script ; ; If you're having trouble loading a DLL file, copy the DLL file to the same ; folder as the running script, and compile the script into an EXE file. ; ; @error: 1 = $sDllPath is not specified and "Delete.dll" or ; "Delete_x64.dll" is not located with the running script ; 2 = "Delete.dll" or "Delete_x64.dll" cannot be found in $sDllPath Func DeleteInitDll( $sDllPath = "" ) ; $sDllPath must be the path WITHOUT DLL filename Static $hDeleteDll = 0 If $hDeleteDll Then Return $hDeleteDll If $sDllPath = "IsDeleteInitDll" Then Return $hDeleteDll Local $sDllFile = @AutoItX64 ? "Delete_x64.dll" : "Delete.dll" If Not $sDllPath Then If FileExists( $sDllFile ) Then $sDllPath = ".\" Else ConsoleWrite( "File path (without DLL filename) for """ & $sDllFile & """ must be specified, or" & @CRLF & _ """ & $sDllFile & "" must be placed in the same folder as the running script." & @CRLF ) Return SetError(1,0,0) EndIf EndIf If StringRight( $sDllPath, 1 ) <> "\" Then $sDllPath &= "\" If Not FileExists( $sDllPath & $sDllFile ) Then ConsoleWrite( "DLL file """ & $sDllPath & $sDllFile & """ cannot be found" & @CRLF ) Return SetError(2,0,0) EndIf $hDeleteDll = DllOpen( $sDllPath & $sDllFile ) EndFunc DeleteColumns is optimized with VB code, but only the source code is delivered in the zip-file. The code is stored in Sources\Delete.vb. Delete.vb can be loaded in two ways. It can be compiled and loaded on the fly directly from the source. Or it can be compiled into a .NET assembly dll-file and loaded from the dll-file. You have to create the .NET assembly dll-file yourself with Utilities\Delete_CreateDLL.au3. When you run this script Delete.vb is compiled into a dll-file and stored as DLLFiles\DeleteVb.dll. The same dll-file can be used in 32 and 64 bit code. There are two reasons why you have to create the .NET assembly dll-file yourself: You can create the dll-file with your installed version of .NET Framework There is no need to deliver a .NET assembly dll-file in the zip-file DeleteInitVbSrc() in Initialization.au3 compiles and loads Delete.vb on the fly: ; Compile and load .NET code from source file ; The source file must be specified with a full path ; Or it must be specified with a path relative to the running script Func DeleteInitVbSrc( $sSrcPath ) Static $bIsDeleteInitVbSrc = 0 If $sSrcPath = "IsDeleteInitVbSrc" Then Return $bIsDeleteInitVbSrc If Not FileExists( $sSrcPath ) Then ConsoleWrite( "Source file """ & $sSrcPath & """ cannot be found" & @CRLF ) Return SetError(2,0,0) EndIf ; Compile and load VB code Local $oNetCode = DotNet_LoadVBcode( FileRead( $sSrcPath ), "System.dll" ) DeleteInit( $oNetCode ) $bIsDeleteInitVbSrc = 1 EndFunc DeleteInitVbDll() loads DeleteVb.dll: ; Load .NET code from .NET assembly DLL file ; The DLL file must be specified with a full path ; Or it must be specified with a path relative to the running script ; Or it must be placed in the same folder as the running script ; ; If you're having trouble loading a DLL file, copy the DLL file to the same ; folder as the running script, and compile the script into an EXE file. Func DeleteInitVbDll( $sDllPath = "" ) Static $bIsDeleteInitVbDll = 0 If $sDllPath = "IsDeleteInitVbDll" Then Return $bIsDeleteInitVbDll If Not $sDllPath Then If FileExists( "DeleteVb.dll" ) Then $sDllPath = "DeleteVb.dll" Else ConsoleWrite( "File path for ""DeleteVb.dll"" must be specified, or" & @CRLF & _ """DeleteVb.dll"" must be placed in the same folder as the running script." & @CRLF ) Return SetError(1,0,0) EndIf EndIf If Not FileExists( $sDllPath ) Then ConsoleWrite( "DLL file """ & $sDllPath & """ cannot be found" & @CRLF ) Return SetError(2,0,0) EndIf ; Load DeleteVb.dll Local $oNetCode = DotNet_LoadAssembly( $sDllPath ) DeleteInit( $oNetCode ) $bIsDeleteInitVbDll = 1 EndFunc Examples This is the code for Examples\DeleteColumns\Using Delete.vb\10,000 rows.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "..\..\..\..\Delete\Includes\Delete.au3" DeleteInitVbSrc( "..\..\..\..\Delete\Sources\Delete.vb" ) #include "..\..\..\..\Display\Functions\ArrayDisplayEx\ArrayDisplayEx.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create array Local $iRows = 10000, $iCols = 16 Local $aArray0[$iRows][$iCols] For $i = 0 To $iRows - 1 For $j = 0 To $iCols - 1 $aArray0[$i][$j] = $i & "/" & $j Next Next _ArrayDisplayEx( $aArray0, "$aArray0" ) Local $aArray ; Example 1 $aArray = $aArray0 Local $aIndex1 = 3 ; Delete column 3 DeleteColumns( $aArray, $aIndex1 ) If @error Then Return ConsoleWrite( "DeleteColumns: @error = " & @error & @CRLF ) _ArrayDisplayEx( $aArray, "Example 1" ) ; Example 2 $aArray = $aArray0 Local $aIndex2 = [ 3, 8 ] ; Delete column 3 and 8 DeleteColumns( $aArray, $aIndex2 ) If @error Then Return ConsoleWrite( "DeleteColumns: @error = " & @error & @CRLF ) _ArrayDisplayEx( $aArray, "Example 2" ) ; Example 3 $aArray = $aArray0 Local $aIndex3 = [ [ 3, 2 ], _ ; Delete column 3 and 4 [ 8, 3 ] ] ; Delete column 8, 9, 10 DeleteColumns( $aArray, $aIndex3 ) If @error Then Return ConsoleWrite( "DeleteColumns: @error = " & @error & @CRLF ) _ArrayDisplayEx( $aArray, "Example 3" ) EndFunc Note how Delete.au3 UDF is included and Delete.vb is initialized in top of the script with these lines: #include "..\..\..\..\Delete\Includes\Delete.au3" DeleteInitVbSrc( "..\..\..\..\Delete\Sources\Delete.vb" ) Use these lines to initialize Delete.dll or Delete_x64.dll: #include "..\..\..\Delete\Includes\Delete.au3" DeleteInitDll( "..\..\..\Delete\DLLFiles" ) ; No filename Note how the folders Includes, Sources, and DLLFiles are located just below Delete\. Project example To use Delete.au3 UDF in your own project copy AccArrays\ and Delete\ (and also Display\ if you need display functions) to the project. In a production environment, Delete.vb should be compiled as a .NET assembly dll-file. Delete unnecessary subfolders in Delete\. Use the following code blocks to initialize VB and C++ code. Initialize VB code from source file: #include "Delete\Includes\Delete.au3" DeleteInitVbSrc( "Delete\Sources\Delete.vb" ) Initialize VB code from .NET assembly dll-file: #include "Delete\Includes\Delete.au3" DeleteInitVbDll( "Delete\DLLFiles\DeleteVb.dll" ) Initialize C++ code from dll-files: #include "Delete\Includes\Delete.au3" DeleteInitDll( "Delete\DLLFiles" ) ; No filename Zip-file You need AutoIt 3.3.10 or later. Tested on Windows 10 and Windows 7. Tomorrow some larger examples will be presented that are using AccArrays UDF. That's the really interesting code. Comments are welcome. Let me know if there are any issues. AccArrays.7z1 point
-
.. and don't start firing the same question in PM's to forum members as stated in the forum rules.... For clarity: I am not your BRO !1 point
-
Welcome to AutoIt and the forum! Could you please give meaningful titles to your threads? Attracts much more users to read your thread and to help you with your problem1 point
-
Not much to work with, hopefully this will give you some ideas: #include <IE.au3> Local $oIE = _IECreate("<Url goes here>", 1) _IELoadWait($oIE) Local $oSpans = _IETagNameGetCollection($oIE, "span") For $oSpan In $oSpans If $oSpan.InnerText = "Khác" Then _IEAction($oSpan, "Click") ExitLoop EndIf Next1 point
-
Just one of many different solutions #include <Constants.au3> #include <Array.au3> example() ;========================================================================== ; ;========================================================================== Func example() Const $kDATA = "Account Name: test Account Domain: test Logon ID: aasdfasdf New Account: Security ID: test\test Account Name: test Account Domain: test\test Attributes: SAM Account Name: test Display Name: test, tester tested User Principal Name: test@test.com Home Directory: - Home Drive: - Script Path: - Profile Path: - User Workstations: - Password Last Set: <never> Account Expires: <never> Primary Group ID: 513 Allowed To Delegate To: - Old UAC Value: 0x0 New UAC Value: 0x11 User Account Control: Account Disabled 'Normal Account' - Enabled User Parameters: - SID History: - Logon Hours: <value not set> Additional Information: Privileges" Local $aResult = StringRegExp($kDATA, "Account Name: ([^ ]*).*?SAM Account Name: ([^ ]*)", $STR_REGEXPARRAYMATCH) If IsArray($aResult) Then _ArrayDisplay($aResult) EndFunc1 point
-
Try this ControlClick("Save project as", "", "ToolbarWindow324", "Left" ,1 ,10,10)1 point
-
This is caused by Au3Stripper and the useage of "Call" in the script. Please add the following line at the top of the script and the compiled version should run fine. #Au3Stripper_Ignore_Funcs=Process_Tab*1 point
-
CSVfileDisplay This is copied from the top of CSVfileDisplay.au3: ; Displays a CSV file in a virtual ListView Func CSVfileDisplay( _ $sCSVfile, _ ; Name of CSV file (plain text file) $iEncoding = 128, _ ; File encoding, default is UTF-8 with BOM $cSeparator = "|", _ ; Field separator character, default is "|" $iMax_Fields = 0, _ ; Max. number of data fields in a line in the CSV file $sTitle = "", _ ; GUI title bar text, default title is set to "CSVfileDisplay" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0100, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs ; $iFlags values ; Add required values together ; 0x0000 => Left aligned text ; 0x0002 => Right aligned text ; 0x0004 => Centered text ; 0x0008 => Verbose mode ; 0x0010 => Half-height ListView ; 0x0020 => No grid lines in ListView ; 0x0100 => Calculate $iMax_Fields from first line ; 0x0200 => Calculate $iMax_Fields from first 10 lines ; 0x0400 => Calculate $iMax_Fields from first 100 lines ; $aFeatures parameter ; Features available in CSVfileDisplay: ; ; Features implemented through Common\ files (always usable): ; "ColAlign" => Column alignment ; "ColWidthMin" => Min. column width ; "ColWidthMax" => Max. column width ; "BackColor" => Listview background color ; "HdrColors" => Listview header background colors ; "UserFunc" => User supplied function ; ; Features implemented through include files ; End user features: ; Include file: ; "ColFormats" => Column text formats ; <Display function>_ColumnFormats.au3 ; "ColColors" => Column background colors ; <Display function>_ColumnColors.au3 ; "SortRows" => Sort rows in data source by index ; <Display function>_SortFuncs.au3 ; "SortCols" => Sort columns in data source by index ; <Display function>_SortFuncs.au3 ; "SortByCols" => Sort rows by multiple columns ; <Display function>_SortFuncs.au3 ; ; See DisplayFeatures.txt for docu of features ; Error codes in @error ; 1 => CSV file does not exist ; 2 => Invalid CSV file passed to function ; 3 => Missing include file ; 4 => Unsupported feature ; 6 => Too many GUIs The first four function parameters are related to the data source, the CSV file. $sCSVfile is the file name, $iEncoding is the file encoding, $sSeparator is the field separator character and $iMax_Fields is the maximum number of data fields in a line in the CSV file. The default value of $iMax_Fields is zero which means that the number of data fields is calculated automatically by inspecting the lines in top of the CSV file. How many lines that are inspected is decided through three flag values 0x0100, 0x0200, and 0x0400 which means that 1, 10 and 100 lines in top of the file are inspected. Because this inspection takes time it's limited to 100 lines. If the lines from number 101 to the end of file contains more fields than the first 100 lines you have to set $iMax_Fields manually. If the lines in the file contains 10 fields but you only want to display 7 fields you can set $iMax_Fields = 7. CSVfileDisplay main code The CSV file is loaded into a 1D array, $aCSVfile, with FileReadToArray(). Through $iFrom and $iTo parameters of the caching mechanism in the virtual listview a range of rows in $aCSVfile are split into single fields by the separator character and stored in a 2D array, $aDisplay. The visible listview cells can now be filled with data from $aDisplay. CSVfileDisplay examples Usage of $iMax_Fields and 0x0100, 0x0200, and 0x0400 flags is demonstrated in Examples\CSVfileDisplay\0) Data source\. Usage of additional features is demonstrated in Examples\CSVfileDisplay\1) Single features\. How to use CSVfileDisplay in your own project is demonstrated in Examples\CSVfileDisplay\3) Using function\. Wrapper function In most examples, the parameters $iEncoding, $sSeparator and $iMax_Fields are the same. Therefore, it's convenient to use a wrapper function to execute CSVfileDisplay(). Examples\CSVfileDisplay\CSVfileDisplayWrapper.au3 contains the wrapper function CSVfileDisplayWr() that's used in most of the examples: #include-once #include "..\..\Functions\CSVfileDisplay\CSVfileDisplay.au3" #include "..\..\Resources\CSVfileDisplay\Conv2DArray.au3" #include "..\..\Resources\CSVfileDisplay\Save1DArray.au3" Func CSVfileDisplayWr( _ $sCSVfile, _ ; Name of CSV file (plain text file) $sTitle = "", _ ; GUI title bar text, default title is set to "CSVfileDisplay" $sHeader = "", _ ; ListView header column names, default is "Col0|Col1|Col2|...|ColN" $iFlags = 0x0100, _ ; Set additional options through flag values $aFeatures = "" ) ; 2D array of feature type/info pairs CSVfileDisplay( $sCSVfile, 128, "|", 0, $sTitle, $sHeader, $iFlags, $aFeatures ) EndFunc Note that CSVfileDisplayWr() is very similar to _ArrayDisplayEx(). CSVfileDisplayWrapper.au3 also includes a couple of UDFs that are used to create CSV files on the fly.1 point