Leaderboard
Popular Content
Showing content with the highest reputation on 10/07/2012 in all areas
-
For those who use ListViews and wish to call a Function to grab the contents of the ListView into a 2D array, then _GUICtrlListView_CreateArray() is for you. It will Return an array with the contents of the ListView inc. the number of rows, columns & column names. Simply run the Example to get an idea of the output. Thanks. Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListView_CreateArray ; Description ...: Creates a 2-dimensional array from a listview. ; Syntax ........: _GUICtrlListView_CreateArray($hListView[, $sDelimeter = '|']) ; Parameters ....: $hListView - Control ID/Handle to the control ; $sDelimeter - [optional] One or more characters to use as delimiters (case sensitive). Default is '|'. ; Return values .: Success - The array returned is two-dimensional and is made up of the following: ; $aArray[0][0] = Number of rows ; $aArray[0][1] = Number of columns ; $aArray[0][2] = Delimited string of the column name(s) e.g. Column 1|Column 2|Column 3|Column nth ; $aArray[1][0] = 1st row, 1st column ; $aArray[1][1] = 1st row, 2nd column ; $aArray[1][2] = 1st row, 3rd column ; $aArray[n][0] = nth row, 1st column ; $aArray[n][1] = nth row, 2nd column ; $aArray[n][2] = nth row, 3rd column ; Author ........: guinness ; Remarks .......: GUICtrlListView.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArrayExample use of Function: #include <Array.au3> ; Required only for _ArrayDisplay(). #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $iWidth = 600, $iHeight = 400, $iListView = 0 Local $hGUI = GUICreate('_GUICtrlListView_CreateArray()', $iWidth, $iHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) _CreateListView($hGUI, $iListView) Local $iGetArray = GUICtrlCreateButton('Get Array', $iWidth - 90, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) Local $iRefresh = GUICtrlCreateButton('Refresh', $iWidth - 180, $iHeight - 28, 85, 25) GUICtrlSetResizing(-1, $GUI_DOCKRIGHT + $GUI_DOCKSIZE + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW, $hGUI) Local $aReturn = 0, $aStringSplit = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $iGetArray $aReturn = _GUICtrlListView_CreateArray($iListView, Default) ; Use | as the default delimeter. _ArrayDisplay($aReturn, '_GUICtrlListView_CreateArray() array.') $aStringSplit = StringSplit($aReturn[0][2], '|') _ArrayDisplay($aStringSplit, 'StringSplit() to retrieve column names.') Case $iRefresh GUICtrlDelete($iListView) _CreateListView($hGUI, $iListView) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example Func _CreateListView($hGUI, ByRef $iListView) ; Thanks to AZJIO for this function. Local $aClientSize = WinGetClientSize($hGUI) $iListView = GUICtrlCreateListView('', 0, 0, $aClientSize[0], $aClientSize[1] - 30) GUICtrlSetResizing($iListView, $GUI_DOCKBORDERS) Sleep(250) Local $iColumns = Random(1, 5, 1) __ListViewFill($iListView, $iColumns, Random(25, 100, 1)) ; Fill the ListView with Random data. For $i = 0 To $iColumns _GUICtrlListView_SetColumnWidth($iListView, $i, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($iListView, $i, $LVSCW_AUTOSIZE_USEHEADER) Next EndFunc ;==>_CreateListView Func __ListViewFill($hListView, $iColumns, $iRows) ; Required only for the Example. If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) EndIf Local $fIsCheckboxesStyle = (BitAND(_GUICtrlListView_GetExtendedListViewStyle($hListView), $LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) _GUICtrlListView_BeginUpdate($hListView) For $i = 0 To $iColumns - 1 _GUICtrlListView_InsertColumn($hListView, $i, 'Column ' & $i + 1, 50) _GUICtrlListView_SetColumnWidth($hListView, $i - 1, -2) Next For $i = 0 To $iRows - 1 _GUICtrlListView_AddItem($hListView, 'Row ' & $i + 1 & ': Col 1', $i) If Random(0, 1, 1) And $fIsCheckboxesStyle Then _GUICtrlListView_SetItemChecked($hListView, $i) EndIf For $j = 1 To $iColumns _GUICtrlListView_AddSubItem($hListView, $i, 'Row ' & $i + 1 & ': Col ' & $j + 1, $j) Next Next _GUICtrlListView_EndUpdate($hListView) EndFunc ;==>__ListViewFill1 point
-
String Regular Expression Tester V2
jvanegmond reacted to Szhlopp for a topic
Since there are WAY to many posts on how to SRE something I thought I would create a nice little tester. This thing does SRE and SRER. Loads files to test. Gets internet content to test. And more! Here it is: SRETesterV2.1.au3 Prev DL - 211 Enjoy!1 point -
I think that the op is not searching for this kind of solution rather than look for hex values within a text file. Your solution is working only for case sensitive strings -> Hello World not equal with hello world. Edit: indeed, UTF stuff makes also problems... $sBinaryFile = "test.txt" ; Text contains Hello World ; read binary file $hFile = FileOpen($sBinaryFile, 16) $dBinary = FileRead($hFile) FileClose($hFile) $sSearch = "hello world" $sBinary = BinaryToString($dBinary) If $sSearch = $sBinary Then MsgBox(0, "", $sBinary) @deerhunt713: something like that here? #include <Array.au3> $sText = "This is a text with a hex string in it: fedcba987654321. Needs to be filtered by AutoIt." $aResult = StringRegExp($sText, "b[[:xdigit:]]+b", 3) _ArrayDisplay($aResult, "Possible Hex Values") Br, UEZ1 point
-
An issue : Does not work with specials encodings (e.g : UTF-16XX) My fix : $sBinaryFile = "test.txt" ; Text contains Hello World $sStringToFind = "Hello World" $bStringToFind = StringTrimLeft(Binary($sStringToFind), 2) ; read binary file $hFile = FileOpen($sBinaryFile, 16) $dBinary = FileRead($hFile) FileClose($hFile) $bStringToFind2 = "" For $iOffset = 3 To StringLen($bStringToFind) step 2 $bStringToFind2 &= "00" & StringMid($bStringToFind, $iOffset, 2) Next If StringInStr($dBinary, $bStringToFind) _ Or StringInStr($dBinary, $bStringToFind2) Then MsgBox(64, "", $sStringToFind & " found !") Br, FireFox.1 point
-
There is a potential problem with the code above. Anyone who wants a small challenge; identify the problem and provide, or describe, a solution.1 point
-
@FireFox, I would stick with your examples because the comments you added describe how it works and help a great deal when it comes to modify the scripts.1 point
-
Why not use something like this >> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Local $hGUI = GUICreate('Non Minimizable', 500, 500, -1, -1, $WS_MAXIMIZEBOX) _SetWindowNonMinimizable($hGUI) GUISetState(@SW_SHOW, $hGUI) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _SetWindowNonMinimizable($hWnd) Return _WinAPI_SetWindowLong($hWnd, $GWL_HWNDPARENT, ControlGetHandle('[CLASS:Progman]', '', 'SysListView321')) EndFunc ;==>_SetWindowNonMinimizable1 point