Leaderboard
Popular Content
Showing content with the highest reputation on 04/27/2018 in all areas
-
FSMudf is a sub-UDF of FAMudf, Fast Array Management Functions UDF. FAMudf is needed to use FSMudf. Note that FAMudf.7z is updated with new SQLite display functions that are required to run examples. FASudf, Fast Array Sorting and Management Functions UDF is needed to run examples (Resources\CreateDBs.au3). Installing SQLite Navigate to Precompiled Binaries for Windows and download the three zip-files. Extract sqlite3.dll from sqlite-dll-win64-x64-3230100.zip and rename it to sqlite3_x64.dll Extract sqlite3.dll from sqlite-dll-win32-x86-3230100.zip Extract the 3 files in sqlite-tools-win32-x86-3230100.zip Copy all 5 files to C:\Windows\System32 Copy sqlite3.dll to C:\Windows\SysWOW64 FSMudf This is the list of functions as shown in Includes\SQLiteFuncs.au3: ; Functions\Initialization.au3 ; ---------------------------- ; FSM_SQLiteFuncsInitDll Load compiled code from C++ DLL file ; Functions\SQLiteFuncs.au3 ; ---------------------------- ; _SQLite_Get_TableA Passes out the results from a SQL query as a 1D/2D array, ANSI version ; _SQLite_Get_TableW Passes out the results from a SQL query as a 1D/2D array, WCHAR (Unicode) version ; _SQLite_Get_TableWEx Passes out the results from a SQL query as a 1D/2D array, WCHAR (Unicode) version ; Optimized C++ code #include-once #include "Functions\Initialization.au3" #include "Functions\SQLiteFuncs.au3" The main code is based on sqlite3_get_table. sqlite3_get_table extracts all elements from the data source at once and inserts the elements in a C-array as strings (more precisely as pointers to zero-terminated UTF-8 strings). The three _SQLite_Get_Table* functions extracts data from the C-array and stores data in native AutoIt arrays. Note that sqlite3_get_table can use a lot of memory for large data sources because all data elements are stored in the C-array. NULL-values are stored as "NULL" in result arrays. Since sqlite3_get_table treats all data as strings, BLOB-data should be excluded. Both _SQLite_Get_TableA and _SQLite_Get_TableWEx are copied and updated from this post in Accessing AutoIt Variables. The most interesting function is _SQLite_Get_TableWEx which is optimized with C++ code. _SQLite_Get_TableWEx ; Passes out the results from a SQL query as a 1D/2D array, WCHAR (Unicode) version, optimized C++ code Func _SQLite_Get_TableWEx( _ $hDB, _ ; An open database $sSQL, _ ; SQL to be executed ByRef $aResult, _ ; Results of the query ByRef $iRows, _ ; Number of result rows ByRef $iCols, _ ; Number of result columns $bNames = True ) ; Include column names If Not FSM_SQLiteFuncsInitDll( "IsFSM_SQLiteFuncsInitDll" ) Then Return SetError(3,0,0) Local $pResult, $iRet = sqlite3_get_table( $hDB, $sSQL, $pResult, $iRows, $iCols ), $pResult0 = $pResult If @error Then Return SetError(@error, @extended, $iRet) $iRows += $bNames If Not $bNames Then $pResult += $iCols * ( @AutoItX64 ? 8 : 4 ) ; Pass data to method Local $aData = [ $pResult, $iRows, $iCols ] FAM_PassDataToMethod( 0, $aData ) ; Execute method $aResult = "" AccArrays01( _SQLite_Get_TableWEx_Mtd, $aResult ) sqlite3_free_table( $pResult0 ) EndFunc ; Record the complete query results from one or more queries as a C-array Func sqlite3_get_table( _ $hDB, _ ; An open database $sSQL, _ ; SQL to be executed ByRef $pResult, _ ; Results of the query ByRef $iRows, _ ; Number of result rows ByRef $iCols ) ; Number of result columns If __SQLite_hChk($hDB, 2) Then Return SetError(@error, 0, $SQLITE_MISUSE) Local $tSQL8 = __SQLite_StringToUtf8Struct($sSQL) If @error Then Return SetError(3, @error, 0) Local $avRval = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_get_table", _ "ptr", $hDB, _ ; An open database "struct*", $tSQL8, _ ; SQL to be executed "ptr*", 0, _ ; Results of the query "int*", 0, _ ; Number of result rows "int*", 0, _ ; Number of result columns "long*", 0) ; Error msg written here If @error Then Return SetError(1, @error, $SQLITE_MISUSE) ; DllCall error $pResult = $avRval[3] $iRows = $avRval[4] $iCols = $avRval[5] EndFunc Func _SQLite_Get_TableWEx_Mtd( $pvResult ) ; Get data Local $aData FAM_PassDataToMethod( 1, $aData ) Local $pResult = $aData[0], $iRows = $aData[1], $iCols = $aData[2] ; Create SAFEARRAYBOUND structure for one or two dimensions Local $tSafeArrayBound = DllStructCreate( $tagSAFEARRAYBOUND & ( $iCols > 1 ? $tagSAFEARRAYBOUND : "" ) ) If $iCols > 1 Then DllStructSetData( $tSafeArrayBound, 1, $iCols ) ; Dimension 2: Elements DllStructSetData( $tSafeArrayBound, $iCols>1?3:1, $iRows ) ; Dimension 1: Elements ; Create safearray of BSTRs for one or two dimensions Local $pSafeArray = SafeArrayCreate( $VT_BSTR, $iCols > 1 ? 2 : 1, $tSafeArrayBound ) ; Pointer to data Local $pSafeArrayData SafeArrayAccessData( $pSafeArray, $pSafeArrayData ) ; Fill safearray DllCall( FSM_SQLiteFuncsInitDll(), "int", "GetTableW", "int", $iRows * $iCols, "ptr", $pResult, "ptr", $pSafeArrayData ) SafeArrayUnaccessData( $pSafeArray ) ; --- Set $pvResult to match an array --- ; Set vt element to $VT_ARRAY + $VT_BSTR DllStructSetData( DllStructCreate( "word", $pvResult ), 1, $VT_ARRAY + $VT_BSTR ) ; Set data element to safearray pointer DllStructSetData( DllStructCreate( "ptr", $pvResult + 8 ), 1, $pSafeArray ) ; <<<< On function exit the safearray contained in a variant is converted to a native AutoIt array >>>> EndFunc SQLiteFuncs.cpp #include <Windows.h> #include <OleAuto.h> int __stdcall GetTableW( int iElements, char **pResult, BSTR *pSafeArrayData ) { int iCharSize; for ( int i = 0; i < iElements; i++ ) { if ( pResult[i] == NULL ) { pSafeArrayData[i] = SysAllocString( L"NULL" ); continue; } iCharSize = MultiByteToWideChar( CP_UTF8, 0, pResult[i], -1, NULL, 0 ); pSafeArrayData[i] = SysAllocStringLen( NULL, iCharSize ); MultiByteToWideChar( CP_UTF8, 0, pResult[i], -1, pSafeArrayData[i], iCharSize ); } return 0; } Create DBs Run CreateDBs.au3 in Resources\ to create test databases. A table is created from an input array of random data generated with FASudf. The database tables contains from 10,000 - 2,000,000 rows and 7 columns. The column data types are integers, strings, integers, floats, dates (integers), times (integers) and row/col (strings). Inserting rows in the tables is implemented through bulk insertions to improve performance. This is a picture of a running CreateDBs.au3: The green bar is a progress bar. Examples Examples\_SQLite_Get_TableWEx.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include "..\..\FSMudf\Includes\SQLiteFuncs.au3" FSM_SQLiteFuncsInitDll( "..\..\FSMudf\DLLFiles" ) #include "..\..\Display\Display.au3" Opt( "MustDeclareVars", 1 ) Example( "10000.db" ) Func Example( $sDB ) _SQLite_Startup() _SQLite_Open( "..\..\FSMudf\Resources\" & $sDB ) Local $hQuery, $aNames, $sHeader Local $sSQL = "SELECT * FROM MyTable;" _SQLite_Query( -1, $sSQL, $hQuery ) _SQLite_FetchNames( $hQuery, $aNames ) _SQLite_QueryFinalize( $hQuery ) For $i = 0 To UBound( $aNames ) - 1 $sHeader &= $aNames[$i] & "|" Next Local $aResult, $iRows, $iCols _SQLite_Get_TableWEx( -1, $sSQL, $aResult, $iRows, $iCols, False ) _ArrayDisplayEx( $aResult, "", $sHeader ) _SQLite_Close() _SQLite_Shutdown() EndFunc Runtimes A few weeks ago, SQLite display functions were published to display data from SQLite databases in virtual listviews. Code sections like this were used to create sorting indexes: ; Sort by dates and times ascending _SQLite_Exec( -1, "CREATE TABLE IF NOT EXISTS DTIndexAsc AS SELECT Mytable.RowId AS RowIndex FROM MyTable ORDER BY Dates,Times;" ) _SQLite_GetTable( -1, "SELECT RowIndex FROM DTIndexAsc;", $aIndex, $iRows, $iColumns ) Local $aDTIndexAsc[$iRows] For $i = 0 To $iRows - 1 $aDTIndexAsc[$i] = $aIndex[$i+2] + 0 Next ; Sort by dates and times descending _SQLite_Exec( -1, "CREATE TABLE IF NOT EXISTS DTIndexDesc AS SELECT Mytable.RowId AS RowIndex FROM MyTable ORDER BY Dates DESC,Times DESC;" ) _SQLite_GetTable( -1, "SELECT RowIndex FROM DTIndexDesc;", $aIndex, $iRows, $iColumns ) Local $aDTIndexDesc[$iRows] For $i = 0 To $iRows - 1 $aDTIndexDesc[$i] = $aIndex[$i+2] + 0 Next The function _SQLite_GetTable (in SQLite.au3) is used to extract the index from the database as a 1D array. _SQLite_GetTable executes quite a lot of code and is not fast if there are more than 100,000 rows in the index. That's a problem for the SQLite display functions that are designed to be fast functions. The problem can be solved by using _SQLite_Get_TableWEx to extract the index. The runtime measurements below compares _SQLite_GetTable and _SQLite_Get_TableWEx when they are used to extract the indexes in "DataDisplay\Examples\SQLiteDisplay\1) Single features\SortByCols.au3" in SQLite display functions. _SQLite_Get_TableWEx is 40 - 70 times faster than _SQLite_GetTable for 100,000 and more rows. SortByMultCols, 32 bit, with sorting, res.au3: 10000.db 10000.db 10,000 rows, 7 columns 10,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 145.1446 Sort by dates and times ascending ... 141.5637 Load asc index with _SQLite_GetTable ... 530.7759 Load index with _SQLite_Get_TableWEx ... 37.1277 Convert asc index to array of ints ... 9.9348 Convert asc index to array of ints ... 18.2156 Sort by dates and times descending ... 138.9933 Sort by dates and times descending ... 159.1532 Load desc index with _SQLite_GetTable ... 548.0105 Load index with _SQLite_Get_TableWEx ... 32.6165 Convert desc index to array of ints ... 10.1298 Convert desc index to array of ints ... 18.9683 Sort by integers ascending ... 141.4529 Sort by integers ascending ... 119.9954 Load asc index with _SQLite_GetTable ... 555.4392 Load index with _SQLite_Get_TableWEx ... 29.1746 Convert asc index to array of ints ... 10.0639 Convert asc index to array of ints ... 21.4630 Sort by integers descending ... 105.6408 Sort by integers descending ... 146.2417 Load desc index with _SQLite_GetTable ... 511.1149 Load index with _SQLite_Get_TableWEx ... 26.9156 Convert desc index to array of ints ... 10.2198 Convert desc index to array of ints ... 19.5490 Sort by rowcol ... 4.9631 Sort by rowcol ... 5.6856 Display table ... Display table ... 50000.db 50000.db 50,000 rows, 7 columns 50,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 226.8609 Sort by dates and times ascending ... 262.4392 Load asc index with _SQLite_GetTable ... 2604.3736 Load index with _SQLite_Get_TableWEx ... 87.3304 Convert asc index to array of ints ... 51.5826 Convert asc index to array of ints ... 49.2577 Sort by dates and times descending ... 188.8095 Sort by dates and times descending ... 214.4735 Load desc index with _SQLite_GetTable ... 2582.5745 Load index with _SQLite_Get_TableWEx ... 68.6275 Convert desc index to array of ints ... 51.7762 Convert desc index to array of ints ... 48.4177 Sort by integers ascending ... 175.0653 Sort by integers ascending ... 199.8655 Load asc index with _SQLite_GetTable ... 2573.7460 Load index with _SQLite_Get_TableWEx ... 85.5111 Convert asc index to array of ints ... 52.2292 Convert asc index to array of ints ... 52.0790 Sort by integers descending ... 158.0193 Sort by integers descending ... 180.4677 Load desc index with _SQLite_GetTable ... 2569.1081 Load index with _SQLite_Get_TableWEx ... 100.6264 Convert desc index to array of ints ... 53.3551 Convert desc index to array of ints ... 46.7262 Sort by rowcol ... 25.3562 Sort by rowcol ... 25.1772 Display table ... Display table ... 100000.db 100000.db 100,000 rows, 7 columns 100,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 216.4729 Sort by dates and times ascending ... 299.9148 Load asc index with _SQLite_GetTable ... 5112.4636 Load index with _SQLite_Get_TableWEx ... 122.1789 Convert asc index to array of ints ... 105.2914 Convert asc index to array of ints ... 95.5248 Sort by dates and times descending ... 444.2007 Sort by dates and times descending ... 238.4213 Load desc index with _SQLite_GetTable ... 5135.0398 Load index with _SQLite_Get_TableWEx ... 107.8501 Convert desc index to array of ints ... 105.2233 Convert desc index to array of ints ... 95.5043 Sort by integers ascending ... 299.7295 Sort by integers ascending ... 256.2663 Load asc index with _SQLite_GetTable ... 5145.4701 Load index with _SQLite_Get_TableWEx ... 109.8088 Convert asc index to array of ints ... 104.0583 Convert asc index to array of ints ... 101.4750 Sort by integers descending ... 291.4356 Sort by integers descending ... 313.4189 Load desc index with _SQLite_GetTable ... 5145.6136 Load index with _SQLite_Get_TableWEx ... 106.5323 Convert desc index to array of ints ... 107.3509 Convert desc index to array of ints ... 96.1193 Sort by rowcol ... 51.4139 Sort by rowcol ... 54.0834 Display table ... Display table ... 500000.db 500000.db 500,000 rows, 7 columns 500,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 806.3354 Sort by dates and times ascending ... 892.4446 Load asc index with _SQLite_GetTable ... 25527.3910 Load index with _SQLite_Get_TableWEx ... 457.0484 Convert asc index to array of ints ... 524.8282 Convert asc index to array of ints ... 481.0475 Sort by dates and times descending ... 852.3726 Sort by dates and times descending ... 860.3113 Load desc index with _SQLite_GetTable ... 25605.2515 Load index with _SQLite_Get_TableWEx ... 417.6269 Convert desc index to array of ints ... 527.6528 Convert desc index to array of ints ... 477.9776 Sort by integers ascending ... 755.4579 Sort by integers ascending ... 757.7121 Load asc index with _SQLite_GetTable ... 25675.2018 Load index with _SQLite_Get_TableWEx ... 464.5835 Convert asc index to array of ints ... 531.9618 Convert asc index to array of ints ... 484.2971 Sort by integers descending ... 647.1808 Sort by integers descending ... 1090.7365 Load desc index with _SQLite_GetTable ... 25608.5690 Load index with _SQLite_Get_TableWEx ... 442.4290 Convert desc index to array of ints ... 530.2276 Convert desc index to array of ints ... 483.2574 Sort by rowcol ... 257.8365 Sort by rowcol ... 259.4505 Display table ... Display table ... 1000000.db 1000000.db 1,000,000 rows, 7 columns 1,000,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 1487.5694 Sort by dates and times ascending ... 1652.0749 Load asc index with _SQLite_GetTable ... 51230.0474 Load index with _SQLite_Get_TableWEx ... 834.6656 Convert asc index to array of ints ... 1049.9148 Convert asc index to array of ints ... 956.6362 Sort by dates and times descending ... 1757.4797 Sort by dates and times descending ... 1382.4794 Load desc index with _SQLite_GetTable ... 51054.0285 Load index with _SQLite_Get_TableWEx ... 844.8572 Convert desc index to array of ints ... 1048.6826 Convert desc index to array of ints ... 952.6937 Sort by integers ascending ... 1146.5287 Sort by integers ascending ... 1260.0946 Load asc index with _SQLite_GetTable ... 50953.7581 Load index with _SQLite_Get_TableWEx ... 873.6447 Convert asc index to array of ints ... 1052.2763 Convert asc index to array of ints ... 952.4081 Sort by integers descending ... 1202.5926 Sort by integers descending ... 1209.9363 Load desc index with _SQLite_GetTable ... 51029.9517 Load index with _SQLite_Get_TableWEx ... 854.2589 Convert desc index to array of ints ... 1050.6820 Convert desc index to array of ints ... 957.5352 Sort by rowcol ... 515.9625 Sort by rowcol ... 513.5077 Display table ... Display table ... 2000000.db 2000000.db 2,000,000 rows, 7 columns 2,000,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 3422.4791 Sort by dates and times ascending ... 3395.0194 Load asc index with _SQLite_GetTable ... 102323.3789 Load index with _SQLite_Get_TableWEx ... 1764.2740 Convert asc index to array of ints ... 2132.7891 Convert asc index to array of ints ... 1919.4284 Sort by dates and times descending ... 2811.0550 Sort by dates and times descending ... 3199.8887 Load desc index with _SQLite_GetTable ... 102314.9121 Load index with _SQLite_Get_TableWEx ... 1796.9594 Convert desc index to array of ints ... 2137.8481 Convert desc index to array of ints ... 1930.9825 Sort by integers ascending ... 2523.2688 Sort by integers ascending ... 2360.2149 Load asc index with _SQLite_GetTable ... 102350.4757 Load index with _SQLite_Get_TableWEx ... 1755.1357 Convert asc index to array of ints ... 2169.7877 Convert asc index to array of ints ... 1929.2912 Sort by integers descending ... 2666.8068 Sort by integers descending ... 2618.3271 Load desc index with _SQLite_GetTable ... 102249.5368 Load index with _SQLite_Get_TableWEx ... 1771.9980 Convert desc index to array of ints ... 2162.3654 Convert desc index to array of ints ... 1933.3957 Sort by rowcol ... 1020.9946 Sort by rowcol ... 1022.1221 Display table ... Display table ... SortByMultCols, 64 bit, without sorting, res.au3: 10000.db 10000.db 10,000 rows, 7 columns 10,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 0.5646 Sort by dates and times ascending ... 0.4674 Load asc index with _SQLite_GetTable ... 417.8308 Load index with _SQLite_Get_TableWEx ... 11.1329 Convert asc index to array of ints ... 8.6621 Convert asc index to array of ints ... 13.4027 Sort by dates and times descending ... 0.1881 Sort by dates and times descending ... 0.2953 Load desc index with _SQLite_GetTable ... 407.9304 Load index with _SQLite_Get_TableWEx ... 6.4239 Convert desc index to array of ints ... 8.5864 Convert desc index to array of ints ... 11.4227 Sort by integers ascending ... 0.1837 Sort by integers ascending ... 0.2582 Load asc index with _SQLite_GetTable ... 405.9565 Load index with _SQLite_Get_TableWEx ... 8.5629 Convert asc index to array of ints ... 8.4277 Convert asc index to array of ints ... 8.1426 Sort by integers descending ... 0.1803 Sort by integers descending ... 0.1856 Load desc index with _SQLite_GetTable ... 413.6196 Load index with _SQLite_Get_TableWEx ... 5.9344 Convert desc index to array of ints ... 8.8632 Convert desc index to array of ints ... 8.1412 Sort by rowcol ... 4.2248 Sort by rowcol ... 4.2724 Display table ... Display table ... 50000.db 50000.db 50,000 rows, 7 columns 50,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 0.5884 Sort by dates and times ascending ... 1.2757 Load asc index with _SQLite_GetTable ... 2103.0735 Load index with _SQLite_Get_TableWEx ... 45.9596 Convert asc index to array of ints ... 44.7805 Convert asc index to array of ints ... 41.0902 Sort by dates and times descending ... 0.2017 Sort by dates and times descending ... 0.2081 Load desc index with _SQLite_GetTable ... 2076.3462 Load index with _SQLite_Get_TableWEx ... 32.7278 Convert desc index to array of ints ... 44.8958 Convert desc index to array of ints ... 42.2457 Sort by integers ascending ... 0.2009 Sort by integers ascending ... 0.2036 Load asc index with _SQLite_GetTable ... 2084.3007 Load index with _SQLite_Get_TableWEx ... 31.3150 Convert asc index to array of ints ... 44.5232 Convert asc index to array of ints ... 40.8115 Sort by integers descending ... 0.2025 Sort by integers descending ... 0.2092 Load desc index with _SQLite_GetTable ... 2077.9852 Load index with _SQLite_Get_TableWEx ... 32.0799 Convert desc index to array of ints ... 45.1648 Convert desc index to array of ints ... 40.9486 Sort by rowcol ... 22.0091 Sort by rowcol ... 22.4202 Display table ... Display table ... 100000.db 100000.db 100,000 rows, 7 columns 100,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 0.3660 Sort by dates and times ascending ... 0.3349 Load asc index with _SQLite_GetTable ... 4161.5110 Load index with _SQLite_Get_TableWEx ... 63.0222 Convert asc index to array of ints ... 90.3332 Convert asc index to array of ints ... 85.2626 Sort by dates and times descending ... 0.2014 Sort by dates and times descending ... 0.2045 Load desc index with _SQLite_GetTable ... 4155.9432 Load index with _SQLite_Get_TableWEx ... 64.5647 Convert desc index to array of ints ... 90.2999 Convert desc index to array of ints ... 80.4228 Sort by integers ascending ... 0.2056 Sort by integers ascending ... 0.2097 Load asc index with _SQLite_GetTable ... 4178.6196 Load index with _SQLite_Get_TableWEx ... 63.4502 Convert asc index to array of ints ... 104.8354 Convert asc index to array of ints ... 88.9006 Sort by integers descending ... 0.1986 Sort by integers descending ... 0.2995 Load desc index with _SQLite_GetTable ... 4184.0656 Load index with _SQLite_Get_TableWEx ... 61.9553 Convert desc index to array of ints ... 93.3349 Convert desc index to array of ints ... 84.9720 Sort by rowcol ... 43.3103 Sort by rowcol ... 44.7650 Display table ... Display table ... 500000.db 500000.db 500,000 rows, 7 columns 500,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 0.3255 Sort by dates and times ascending ... 0.3585 Load asc index with _SQLite_GetTable ... 21220.7373 Load index with _SQLite_Get_TableWEx ... 340.0055 Convert asc index to array of ints ... 454.1742 Convert asc index to array of ints ... 410.1735 Sort by dates and times descending ... 0.2219 Sort by dates and times descending ... 0.2211 Load desc index with _SQLite_GetTable ... 21250.0097 Load index with _SQLite_Get_TableWEx ... 317.6836 Convert desc index to array of ints ... 453.9035 Convert desc index to array of ints ... 410.4497 Sort by integers ascending ... 0.2244 Sort by integers ascending ... 0.2130 Load asc index with _SQLite_GetTable ... 21190.8114 Load index with _SQLite_Get_TableWEx ... 317.2279 Convert asc index to array of ints ... 458.1419 Convert asc index to array of ints ... 413.1949 Sort by integers descending ... 0.2366 Sort by integers descending ... 0.2205 Load desc index with _SQLite_GetTable ... 21240.0148 Load index with _SQLite_Get_TableWEx ... 315.8386 Convert desc index to array of ints ... 467.6600 Convert desc index to array of ints ... 413.8453 Sort by rowcol ... 223.0996 Sort by rowcol ... 227.9657 Display table ... Display table ... 1000000.db 1000000.db 1,000,000 rows, 7 columns 1,000,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 0.3399 Sort by dates and times ascending ... 0.3302 Load asc index with _SQLite_GetTable ... 42514.1138 Load index with _SQLite_Get_TableWEx ... 643.0386 Convert asc index to array of ints ... 906.9693 Convert asc index to array of ints ... 818.4471 Sort by dates and times descending ... 0.2491 Sort by dates and times descending ... 0.2269 Load desc index with _SQLite_GetTable ... 42535.1586 Load index with _SQLite_Get_TableWEx ... 635.4573 Convert desc index to array of ints ... 914.8249 Convert desc index to array of ints ... 814.0954 Sort by integers ascending ... 0.2651 Sort by integers ascending ... 0.2399 Load asc index with _SQLite_GetTable ... 42571.1798 Load index with _SQLite_Get_TableWEx ... 637.1402 Convert asc index to array of ints ... 924.1231 Convert asc index to array of ints ... 822.8766 Sort by integers descending ... 0.2726 Sort by integers descending ... 0.2455 Load desc index with _SQLite_GetTable ... 42548.2025 Load index with _SQLite_Get_TableWEx ... 628.0942 Convert desc index to array of ints ... 937.4548 Convert desc index to array of ints ... 823.7806 Sort by rowcol ... 438.8201 Sort by rowcol ... 453.7171 Display table ... Display table ... 2000000.db 2000000.db 2,000,000 rows, 7 columns 2,000,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Sort by dates and times ascending ... 0.3402 Sort by dates and times ascending ... 0.3391 Load asc index with _SQLite_GetTable ... 85582.1108 Load index with _SQLite_Get_TableWEx ... 1343.2268 Convert asc index to array of ints ... 1868.8664 Convert asc index to array of ints ... 1645.0853 Sort by dates and times descending ... 0.3034 Sort by dates and times descending ... 0.2826 Load desc index with _SQLite_GetTable ... 85125.7264 Load index with _SQLite_Get_TableWEx ... 1327.8081 Convert desc index to array of ints ... 1883.5679 Convert desc index to array of ints ... 1647.1631 Sort by integers ascending ... 0.3383 Sort by integers ascending ... 0.2416 Load asc index with _SQLite_GetTable ... 85248.6628 Load index with _SQLite_Get_TableWEx ... 1300.6246 Convert asc index to array of ints ... 1914.6174 Convert asc index to array of ints ... 1639.7942 Sort by integers descending ... 0.4189 Sort by integers descending ... 0.3053 Load desc index with _SQLite_GetTable ... 85243.5332 Load index with _SQLite_Get_TableWEx ... 1293.3039 Convert desc index to array of ints ... 2010.6404 Convert desc index to array of ints ... 1678.0005 Sort by rowcol ... 882.9645 Sort by rowcol ... 901.0884 Display table ... Display table ... Runtime measurements for the three _SQLite_Get_Table* functions compared to _SQLite_GetTable2d (in SQLite.au3): Code executed as 32 bit code Code executed as 64 bit code ============================ ============================ 10000.db 10000.db 10,000 rows, 7 columns 10,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Extract data with _SQLite_GetTable2d ... 1459.3627 Extract data with _SQLite_GetTable2d ... 1181.4001 Extract data with _SQLite_Get_TableA ... 686.4455 Extract data with _SQLite_Get_TableA ... 560.7858 Extract data with _SQLite_Get_TableW ... 1894.6954 Extract data with _SQLite_Get_TableW ... 1438.9197 Extract data with _SQLite_Get_TableWEx ... 57.4431 Extract data with _SQLite_Get_TableWEx ... 43.5755 50000.db 50000.db 50,000 rows, 7 columns 50,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Extract data with _SQLite_GetTable2d ... 7326.2039 Extract data with _SQLite_GetTable2d ... 5855.6212 Extract data with _SQLite_Get_TableA ... 3456.1112 Extract data with _SQLite_Get_TableA ... 2815.5756 Extract data with _SQLite_Get_TableW ... 9460.7205 Extract data with _SQLite_Get_TableW ... 7192.0603 Extract data with _SQLite_Get_TableWEx ... 308.1110 Extract data with _SQLite_Get_TableWEx ... 240.5781 100000.db 100000.db 100,000 rows, 7 columns 100,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Extract data with _SQLite_GetTable2d ... 14713.1044 Extract data with _SQLite_GetTable2d ... 11671.0253 Extract data with _SQLite_Get_TableA ... 6832.4168 Extract data with _SQLite_Get_TableA ... 5623.6683 Extract data with _SQLite_Get_TableW ... 18881.6323 Extract data with _SQLite_Get_TableW ... 14307.3576 Extract data with _SQLite_Get_TableWEx ... 570.2480 Extract data with _SQLite_Get_TableWEx ... 439.9531 500000.db 500000.db 500,000 rows, 7 columns 500,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Extract data with _SQLite_GetTable2d ... 73256.2654 Extract data with _SQLite_GetTable2d ... 58339.9228 Extract data with _SQLite_Get_TableA ... 34176.2231 Extract data with _SQLite_Get_TableA ... 28192.6978 Extract data with _SQLite_Get_TableW ... 94791.4794 Extract data with _SQLite_Get_TableW ... 71838.5087 Extract data with _SQLite_Get_TableWEx ... 2865.7178 Extract data with _SQLite_Get_TableWEx ... 2214.4506 1000000.db 1000000.db 1,000,000 rows, 7 columns 1,000,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Extract data with _SQLite_GetTable2d ... 146762.3736 Extract data with _SQLite_GetTable2d ... 116974.8871 Extract data with _SQLite_Get_TableA ... 68642.1209 Extract data with _SQLite_Get_TableA ... 56409.6025 Extract data with _SQLite_Get_TableW ... 189849.3528 Extract data with _SQLite_Get_TableW ... 143717.5201 Extract data with _SQLite_Get_TableWEx ... 5784.5193 Extract data with _SQLite_Get_TableWEx ... 4438.3908 2000000.db 2000000.db 2,000,000 rows, 7 columns 2,000,000 rows, 7 columns ------------------------------------------------------ ------------------------------------------------------ Extract data with _SQLite_GetTable2d ... 293500.3887 Extract data with _SQLite_GetTable2d ... 234128.4466 Extract data with _SQLite_Get_TableA ... 137109.4020 Extract data with _SQLite_Get_TableA ... 112849.2381 Extract data with _SQLite_Get_TableW ... 380164.0186 Extract data with _SQLite_Get_TableW ... 288153.6158 Extract data with _SQLite_Get_TableWEx ... 11663.6742 Extract data with _SQLite_Get_TableWEx ... 9037.5468 _SQLite_Get_TableWEx is 25 times faster than _SQLite_GetTable2d. _SQLite_Get_TableA is twice as fast as _SQLite_GetTable2d and _SQLite_Get_TableW is slower than _SQLite_GetTable2d. FSMudf.7z FAMudf.7z must be downloaded and unzipped to use FSMudf. Note that FAMudf.7z is updated with new SQLite display functions that are required to run examples. FSMudf.7z must be unzipped in the same folder structure as FAMudf.7z. See Fast Array Management Functions UDF for details. FASudf.7z is needed to run examples (Resources\CreateDBs.au3). Start running the examples in FAMproj\FSMudf\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. FSMudf.7z2 points
-
Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip1 point
-
Simple "chat" program with clickable links
Earthshine reacted to therks for a topic
Turns out that UDF was for naught as it doesn't work the way I hoped it would. However, I've been having a great deal of success with the method I figured out above. This is still a work in progress, but here's what I have so far. #include <GUIConstants.au3> #include <GUIEdit.au3> #include <IE.au3> #include <GuiRichEdit.au3> ;~ #include <Variable.au3> Opt('TrayIconDebug', 1) If $CmdLine[0] And StringInStr(FileGetAttrib($CmdLine[1]), 'D') Then FileChangeDir($CmdLine[1]) EndIf Global $CHAT_FILE = @WorkingDir & '\NetworkChat.txt' ConsoleWrite($CHAT_FILE & @CRLF) Main() Func Main() Local $hGUIMain = GUICreate('Network Chat', 500, 440, Default, Default, $WS_OVERLAPPEDWINDOW) Local $oEmbedIE = _IECreateEmbedded() Local $ob_EmbedIE = GUICtrlCreateObj($oEmbedIE, 5, 5, 490, 300) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _IENavigate($oEmbedIE, 'about:blank') Local $dm_AccelTab = GUICtrlCreateDummy() Local $dm_AccelCtrlA = GUICtrlCreateDummy() Local $dm_AccelEnter = GUICtrlCreateDummy() Local $dm_AccelShiftEnter = GUICtrlCreateDummy() Local $dm_AccelPgUp = GUICtrlCreateDummy() Local $dm_AccelPgDn = GUICtrlCreateDummy() Local $ed_Chat = GUICtrlCreateEdit('', 5, 310, 470, 60, BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKLEFT, $GUI_DOCKRIGHT)) Local $aTabStop = [ 4 * 4 ] _GUICtrlEdit_SetTabStops($ed_Chat, $aTabStop) Local $bt_Send = GUICtrlCreateButton('>', 475, 310, 20, 60) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_DEFBUTTON) Local $ch_Timestamps = GUICtrlCreateCheckbox('Show ×tamps', 5, 375, 200, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKLEFT)) Local $ch_PromptURL = GUICtrlCreateCheckbox('&Confirm before opening links', 5, 395, 200, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKLEFT)) Local $ra_Enter = GUICtrlCreateRadio('&1. Enter to send / Shift+Enter for new line', 280, 375, 215, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKRIGHT)) GUICtrlSetState(-1, $GUI_CHECKED) Local $ra_ShiftEnter = GUICtrlCreateRadio('&2. Shift+Enter to send / Enter for new line', 280, 395, 215, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKSIZE, $GUI_DOCKRIGHT)) Local $lb_Status = GUICtrlCreateLabel(' Chat file: ' & $CHAT_FILE, 0, 420, 500, 20, BitOR($SS_SUNKEN, $SS_CENTERIMAGE)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKSTATEBAR, $GUI_DOCKLEFT, $GUI_DOCKRIGHT)) GUICtrlSetCursor(-1, 0) Local $aAccel = [ _ [ '{enter}', $dm_AccelEnter ], _ [ '+{enter}', $dm_AccelShiftEnter ], _ [ '{tab}', $dm_AccelTab ], _ [ '{pgup}', $dm_AccelPgUp ], _ [ '{pgdn}', $dm_AccelPgDn ], _ [ '^a', $dm_AccelCtrlA ] ] GUISetAccelerators($aAccel) GUISetState() GUICtrlSetState($ed_Chat, $GUI_FOCUS) Local $sHTML, $aChatTime[2], $hFocused, $hIEControl = ControlGetHandle($hGUIMain, '', '[CLASS:Internet Explorer_Server; INSTANCE:1]') While 1 $hFocused = _WinAPI_GetFocus() $aChatTime[0] = FileGetTime($CHAT_FILE, 0, 1) If $aChatTime[0] <> $aChatTime[1] Then $sHTML = _LoadChat(BitAND(GUICtrlRead($ch_Timestamps), $GUI_CHECKED)) _IEDocWriteHTML($oEmbedIE, $sHTML) _IEAction($oEmbedIE, 'refresh') $oEmbedIE.document.parentwindow.scrollTo(0, $oEmbedIE.document.body.scrollHeight) $aChatTime[1] = $aChatTime[0] EndIf If $oEmbedIE.document.location.href <> 'about:blank' Then _IENavigate($oEmbedIE, 'about:blank') $aChatTime[1] = 0 EndIf Local $oAutoItMonitor = $oEmbedIE.document.getElementById('autoit_monitor') If IsObj($oAutoItMonitor) And $oAutoItMonitor.value Then Local $sVal = $oAutoItMonitor.value If StringLeft($sVal, 4) = 'http' Then Local $sVal = StringReplace($sVal, '&', '&') ; For some reason the JavaScript copying the URL always encodes ampersands to html entities If Not BitAND(GUICtrlRead($ch_PromptURL), $GUI_CHECKED) Or (MsgBox(0x124, 'URL', 'Open URL?' & @LF & $sVal, 0, $hGUIMain) = 6) Then ShellExecute($sVal) EndIf ElseIf $sVal = 27 Then ; Escape ExitLoop ElseIf Not ($sVal = 17 Or $sVal >= 35 And $sVal <= 40) Then ; Ctrl, Home, End, Arrow keys ConsoleWrite($sVal & @CRLF) GUICtrlSetState($ed_Chat, $GUI_FOCUS) EndIf $oAutoItMonitor.value = '' EndIf Local $iMsg = GUIGetMsg() Switch $iMsg Case $lb_Status ShellExecute($CHAT_FILE) Case $ch_Timestamps $aChatTime[1] = 0 Case $dm_AccelPgUp $oEmbedIE.document.parentwindow.scrollBy(0, -200) Case $dm_AccelPgDn $oEmbedIE.document.parentwindow.scrollBy(0, 200) Case $dm_AccelCtrlA If $hFocused = GUICtrlGetHandle($ed_Chat) Then _GUICtrlEdit_SetSel($ed_Chat, 0, -1) Case $dm_AccelEnter If $hFocused = GUICtrlGetHandle($ed_Chat) Then If BitAND(GUICtrlRead($ra_Enter), $GUI_CHECKED) Then _SendChat($ed_Chat) Else _GUICtrlEdit_ReplaceSel($ed_Chat, @CRLF) EndIf EndIf Case $dm_AccelShiftEnter If $hFocused = GUICtrlGetHandle($ed_Chat) Then If BitAND(GUICtrlRead($ra_ShiftEnter), $GUI_CHECKED) Then _SendChat($ed_Chat) Else _GUICtrlEdit_ReplaceSel($ed_Chat, @CRLF) EndIf EndIf Case $bt_Send _SendChat($ed_Chat) Case $dm_AccelTab If $hFocused = GUICtrlGetHandle($ed_Chat) Then _GUICtrlEdit_ReplaceSel($ed_Chat, @TAB) Else GUICtrlSetState($ed_Chat, $GUI_FOCUS) EndIf Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc Func _EncodeForFile($sString) $sString = StringStripCR($sString) $sString = StringReplace($sString, '\', '\\') $sString = StringReplace($sString, @LF, '\n') $sString = StringReplace($sString, @TAB, '\t') Return $sString EndFunc Func _EncodeFromFile($sString) $sString = StringReplace($sString, '<', '<') $sString = StringReplace($sString, '>', '>') $sString = StringFormat($sString) $sString = StringReplace($sString, @TAB, ' ') $sString = StringReplace($sString, @LF, '<br />') $sString = StringRegExpReplace($sString, '(https?://\S+)', '<span class="fakelink" onclick="document.getElementById(''autoit_monitor'').value=this.innerHTML">\1</span>') ; Return $sString EndFunc Func _SendChat($iCtrl) Local $sChat = StringStripWS(GUICtrlRead($iCtrl), 3) If $sChat Then FileWrite($CHAT_FILE, @CRLF & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & @TAB & @ComputerName & @TAB & _EncodeForFile($sChat)) GUICtrlSetData($iCtrl, '') Return True EndIf EndFunc Func _LoadChat($iShowTS) Local $aLines = FileReadToArray($CHAT_FILE), _ $sOutput = '<style>' & @CRLF $sOutput &= 'body, table { margin: 0; font-family: Arial; font-size: 0.8em; border-collapse: collapse; width: 100%; } ' & @CRLF $sOutput &= 'tr { vertical-align: top; text-align: left; } ' & @CRLF $sOutput &= '.name_column { white-space: nowrap; } ' & @CRLF $sOutput &= '.text_column { width: 100%; } ' & @CRLF $sOutput &= '.row1 { background: #eee; } ' & @CRLF $sOutput &= '.date { background: #bef; text-align: center; border: solid #000; border-width: 1px 0; } ' & @CRLF $sOutput &= '.fakelink { text-decoration: underline; cursor: pointer; color: #08f; } ' & @CRLF If Not $iShowTS Then $sOutput &= '.timestamp { display: none }' & @CRLF $sOutput &= '</style>' & @CRLF $sOutput &= '<body onkeydown="document.getElementById(''autoit_monitor'').value=event.keyCode">' & @CRLF $sOutput &= '<table>' & @CRLF Local $sDateMem For $L = 0 To @extended-1 If Not $aLines[$L] Then ContinueLoop Local $aRegExLine = StringRegExp($aLines[$L], '(.+)\t(.+)\t(.+)', 1), $sChat If Not @error Then $aDateTime = _FormatTime($aRegExLine[0]) If $aDateTime[0] <> $sDateMem Then $sOutput &= '<tr><th class="date" colspan="2">' & $aDateTime[0] & '</th></tr>' $sDateMem = $aDateTime[0] EndIf $sOutput &= '<tr class="row' & Mod($L, 2) & '">' & _ '<th class="name_column"><span class="timestamp">[' & $aDateTime[1] & '] </span><' & $aRegExLine[1] & '></th>' & _ '<td class="text_column">' & _EncodeFromFile($aRegExLine[2]) & '</td></tr>' & @CRLF EndIf Next $sOutput &= '</table>' $sOutput &= '<input type="hidden" id="autoit_monitor" />' Return $sOutput EndFunc Func _FormatTime($sTime) Local $aMonths = StringSplit('Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec', '|') Local $aReturn[2] Local $aRegEx = StringRegExp($sTime, '(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})', 1) If Not @error Then $aReturn[0] = $aRegEx[0] &'-'& $aMonths[Int($aRegEx[1])] &'-'& $aRegEx[2] $aReturn[1] = $aRegEx[3] &':'& $aRegEx[4] &':'& $aRegEx[5] EndIf Return $aReturn EndFunc1 point -
Here is "GUI Hyperlink control.zip" for download - I get it from my local copy: GUI Hyperlink control.zip1 point
-
Simple "chat" program with clickable links
Earthshine reacted to therks for a topic
Oh for sure. It's working. Just wanted to test it first. It's kind of hacky cus it's not just AutoIt it uses JavaScript too. So basically it goes like this. Instead of actually using links (<a href="">) in the HTML, I'm wrapping the URLs in <span> tags, styled to look like links. When clicking on the <span>, they set a <div> element's innerText to the URL from the span. The AutoIt script is constantly monitoring the <div> tag for changes and when it detects a change, it reads the content and then ShellExecute's it.1 point -
Simple "chat" program with clickable links
Earthshine reacted to therks for a topic
Yeah I've done something like that before, but it won't work here. That's making a label look like a link and then just handling the notification, basically like a button or other notifying control. I can't think of a way to embed something like that within normal text. If I could somehow get the embedded browser to pass the notification of a clicked link back to the AutoIt script I could handle it like that... but.. I just came up with an idea actually.1 point -
You can't have hyphens in a variable name, otherwise you're going to get syntax errors, so change $ohp-select to $ohpselect Also the select option is actually hidden (id = "hp-authn-provider-select") and so you would need to test a, whether you can change the selection and if it has any effect on the "divs" above which are what you actually see on the page. Hope that makes sense.1 point
-
This should be very fast version doing the same: $sFileText = FileRead('ToLine123.txt') $iStart = StringInStr($sFileText,@CRLF,1,704) $iEnd = StringInStr($sFileText,@CRLF,1,739) If $iStart > 0 And $iEnd > 0 Then $sFileLines1 = StringLeft($sFileText, $iStart-1) $sFileLines2 = '' For $i = 1 To 36 ; 739-704+1 $sFileLines2 &= @CRLF Next $sFileLines3 = StringMid($sFileText, $iEnd+1) FileDelete('ToLine123.txt') FileWrite('ToLine123.txt', $sFileLines1 & $sFileLines2 & $sFileLines3) EndIf EDIT: And this should be even faster $sFileText = FileRead('ToLine123.txt') $iStart = StringInStr($sFileText,@CRLF,1,704) ;~ $iEnd = StringInStr($sFileText,@CRLF,1,739) If $iStart > 0 Then $iEnd = StringInStr($sFileText,@CRLF,1,35,$iStart+1) ; 35=739-704 If $iEnd > 0 Then $sFileLines1 = StringLeft($sFileText, $iStart-1) $sFileLines2 = '' For $i = 1 To 36 ; 739-704+1 $sFileLines2 &= @CRLF Next $sFileLines3 = StringMid($sFileText, $iEnd+1) FileDelete('ToLine123.txt') FileWrite('ToLine123.txt', $sFileLines1 & $sFileLines2 & $sFileLines3) EndIf EndIf1 point
-
In your case, your best bet would be to avoid the _FileWriteToLine function. Every time you call that function it re-reads the entire file to an array, replaces one line, then rewrites the file. Also, if you're just filling multiple consecutive lines with blanks you could use a for-loop. I would suggest this: Read the file with FileReadToArray. For loop 704 to 739, replacing array items with blanks. Write the array to file using _FileWriteFromArray (as BrewMan suggested). Something like the following: $aFileLines = FileReadToArray('ToLine123.txt') For $i = 704 To 739 $aFileLines[$i] = '' Next _FileWriteFromArray('ToLine123.txt', $aFileLines) That's untested, and you would want to add error checking, but it should give you an idea where to start.1 point
-
Adapted from OP code... #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Global $DoubleClicked = False $Form1 = GUICreate("Form1", 259, 296, 192, 124) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $ListV1 = GUICtrlCreateListView("ListView 1", 32, 32, 186, 182, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE)) For $i = 1 To 5 GUICtrlCreateListViewItem("Item" & $i, $ListV1) Next GUISetState(@SW_SHOW) While 1 If $DoubleClicked Then DoubleClickFunc() $DoubleClicked = False EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func DoubleClickFunc() MsgBox(64, "OK", "Double Clicked: " & _GUICtrlListView_GetItemTextString($ListV1, -1)) ClipPut(_GUICtrlListView_GetItemTextString($ListV1, -1)) EndFunc ;==>DoubleClickFunc Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam) Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return 0 $code = DllStructGetData($tagNMHDR, 3) If $wParam = $ListV1 And $code = -3 Then $DoubleClicked = True Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY kylomas1 point
-
Why not put all the text into an array, then use _FileWriteFromArray? You can declare your array sized to how ever many lines you're going to need, and then just set the elements with the values you're using.1 point
-
Thanks @AdamUL and @therks. Both ways worked for me.1 point
-
How to translate a C struct containing bit fields using DllStructCreate()?
tukangusil7 reacted to Bilgus for a topic
I don't think there is a direct way to do that in autoit but it is a 32-bit data struct no matter what the function it is passed to treats it as so DllStructCreate("ULONG") would work DllStructCreate("USHORT;USHORT") or even DllStructCreate("BYTE;BYTE;BYTE;BYTE") whatever you pass it to isn't going to care but for you the first will probably be the easiest since to set or retrieve the data it has to be done as a chunk Local $bVirtualizationCandidate, $bVirtualizationEnabled, $bVirtualSource Local $aBits = [1,2,4,8,16] Local $tData = DllStructCreate("ULONG") Somecallthat_changes($tData) $iVal = DllStructGetData($tData, 1) If BitAnd($iVal, $aBits[0]) Then $bVirtualizationCandidate = True If BitAnd($iVal, $aBits[1]) Then $bVirtualizationEnabled = True If BitAnd($iVal, $aBits[4]) Then $bVirtualSource = True ConsoleWrite("$bVirtualizationCandidate = " & ($bVirtualizationCandidate ? "True" : "False") & _ " $bVirtualizationEnabled = " & ($bVirtualizationEnabled ? "True" : "False") & _ " $bVirtualSource = " & ($bVirtualSource ? "True" : "False") &@CRLF) Func SomeCallthat_changes(Byref $tD) Local $iVal = BitOR($aBits[0],$aBits[4]) DllStructsetData($tD, 1, $iVal) EndFunc You don't necessarily need $aBits[] but it makes it easier to grok Also pay attention to the Endian1 point -
What about: #include <IE.au3> Local $oIENew = _IEAttach("https://www.net-inspect.com/AssignWorkflowToDocuments.aspx?b=a2dRm8Epis60nDimF7TNCMPpKxv%2bPGUH4YsewhvFKNU%3d","url") Local $oInputs = _IETagNameGetCollection($oIENew, "input") For $oInput In $oInputs If $oInput.Name = "chkAction" And $oInput.value = "Delete" Then $oInput.Checked = True ExitLoop EndIf Next1 point
-
Simple "chat" program with clickable links
therks reacted to Earthshine for a topic
you may be able to work with this and adapt it.0 points