Search the Community

Showing results for tags 'sort'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Chat
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • Forum
  • AutoIt


  • Community Calendar

Found 13 results

  1. I have a list of filenames and their versions and I want to sort them by the versions. However, they always sort like they were just strings. The version numbers can have up to 4 components (eg: I want version '1.2.7' to sort ahead of '1.12.7', and '1.8 alpha' to sort ahead of '1.8 beta' Here's my array of items to be sorted: 1.5 alpha.22.1\filexxx 1.9\filexxx 1.8beta\filexxx 1.8alpha\filexxx 1.6\filexxx 1.62\filexxx 1.5-alpha.2.1\filexxx 1.2\filexxx 1.11-beta\filexxx I want the sorted list to look like this: 1.2\filexxx 1.5-alpha.2.1\filexxx 1.5 alpha.22.1\filexxx 1.6\filexxx 1.62\filexxx 1.8alpha\filexxx 1.8beta\filexxx 1.9\filexxx 1.11-beta\filexxx But, what I end up with is this: 1.2\filexxx 1.6\filexxx 1.9\filexxx 1.62\filexxx 1.8beta\filexxx 1.8alpha\filexxx 1.11-beta\filexxx 1.5 alpha.22.1\filexxx 1.5-alpha.2.1\filexxx Here is my test script: #include <Debug.au3> _DebugSetup(@ScriptName & "_debug.txt", False, 5, "") _DebugOut("=============== " & @MON & "/" & @MDAY & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & " ====================" & @CRLF) #include <Array.au3> #include <String.au3> test() Func test() Local $ar $ar = StringSplit("", "") _ArrayAdd($ar, "1.5 alpha.22.1\filexxx") _ArrayAdd($ar, "1.9\filexxx") _ArrayAdd($ar, "1.8beta\filexxx") _ArrayAdd($ar, "1.8alpha\filexxx") _ArrayAdd($ar, "1.6\filexxx") _ArrayAdd($ar, "1.62\filexxx") _ArrayAdd($ar, "1.5-alpha.2.1\filexxx") _ArrayAdd($ar, "1.2\filexxx") _ArrayAdd($ar, "1.11-beta\filexxx") dumparray($ar, "$ar - initial values") setupVerSort($ar) ; Prepend each item in the array with a formatted version number dumparray($ar, "$ar - after setup") _ArraySort($ar, 0, 1) ; Sort based on the formatted version numbers cleanupVerSort($ar) ; Strip off the formatted version numbers dumparray($ar, "$ar - after cleanup") EndFunc ;==>test ; For each item in the array, extract the version number part, format it for sorting ; and put the formatted version in front of the item string (separated by " + ") Func setupVerSort(ByRef $ar) Local $ndx, $ndx2, $verIN, $verOUT, $vpartIN, $vpartOUT, $parts, $maxdepth $maxdepth = 4 For $ndx = 1 To UBound($ar) - 1 $verIN = StringSplit($ar[$ndx], "\", 2)[0] ; Get the version number $parts = StringSplit($verIN, '.', 2) ; Split the components into the $parts array redim $parts[$maxdepth] ; Only look at $maxdepth version components ; Format each component to be a set character length (8) For $ndx2 = 0 To UBound($parts) - 1 $vpartIN = $parts[$ndx2] If (StringRegExp($vpartIN, "[a-zA-Z]+")) Then $vpartOUT = StringRegExpReplace($vpartIN, "([a-zA-Z])*", "\0") logmsg("$vpartIN ==>" & $vpartIN & "<==, $vpartOUT ==>" & $vpartOUT & "<==") logmsg("") Else $vpartOUT = $vpartIN EndIf $parts[$ndx2] = StringFormat("%8s", $vpartOUT) ; Format this conponent to be 8 characters wide Next $verOUT = _ArrayToString($parts, ".", 0) $ar[$ndx] = $verOUT & " + " & $ar[$ndx] ; Prepend the formatted version Next EndFunc ;==>setupVerSort Func cleanupVerSort(ByRef $ar) Local $x For $ndx = 1 To UBound($ar) - 1 $x = StringInStr($ar[$ndx], " + ") $ar[$ndx] = StringTrimLeft($ar[$ndx], $x + 2) ; Strip off the formatted version Next EndFunc ;==>cleanupVerSort Func logmsg($msg, $lnum = @ScriptLineNumber) Local $str = ":" & $lnum & ": " & $msg ; Caller's line number plus the caller's message ; Send to both the Console and to DebugOut() _DebugOut($str) ConsoleWrite($str & @CRLF) EndFunc ;==>logmsg Func dumparray(ByRef $ar, $sTitle, $lnum = @ScriptLineNumber) Local $str = @CRLF & " -" & $lnum & "-" & " Dump of " & $sTitle & @CRLF If (IsArray($ar)) Then For $ndx = 0 To UBound($ar) - 1 $str &= " [" & $ndx & "] " & $ar[$ndx] & @CRLF Next Else $str = "<not an array>" EndIf logmsg($str) EndFunc ;==>dumparray
  2. Hi, I have a 2D array with 2 columns, the 1st column contains a "version string" and the 2nd column contains a generic string. I want to sort it in the descending order so the latest version comes first. #include <Array.au3> Local $aVersionsAndReleases[4][2] = [["", "Release #1"], ["", "Release #3"], ["", "Release #4"], ["", "Release #2"]] _ArraySort($aVersionsAndReleases, 1) ConsoleWrite(_ArrayToString($aVersionsAndReleases, ' - ')) _ArrayDisplay($aVersionsAndReleases) Unfortunately, _ArraySort isn't working here . This is the output generated by the script: - Release #4 - Release #3 - Release #1 - Release #2 The expected result should be: - Release #4 - Release #3 - Release #2 - Release #1 I am looking to develop an function which does this... but I don't know where to start . Can someone help me get started? Thanks in Advance! - TD.
  3. Hello guys, I'm working with a simple script, complementing a GUICtrlCreateListView which has 5 columns. I would order the first column so that the numbers are decreasing. #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StructureConstants.au3> Opt('MustDeclareVars', 1) Global $search_LV, $B_DESCENDING GUICreate("ListView Sort by Column Click", 400, 300) $search_LV = GUICtrlCreateListView("String|Number|String", 2, 2, 394, 268) GUICtrlSendMsg($search_LV, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($search_LV, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("line4|5|1A", $search_LV) GUICtrlCreateListViewItem("line5|4.50 |1B", $search_LV) GUICtrlCreateListViewItem("line10|4.0 |2C", $search_LV) GUICtrlCreateListViewItem("line3|23|01", $search_LV) GUICtrlCreateListViewItem("line2|0.34560 |09", $search_LV) GUICtrlCreateListViewItem("line1|1.0 |7A", $search_LV) GUICtrlCreateListViewItem("line1|0.1 |8C", $search_LV) GUICtrlCreateListViewItem("line1|97|5B", $search_LV) GUICtrlCreateListViewItem("line1|910|9B", $search_LV) GUICtrlCreateListViewItem("line1|99|11", $search_LV) GUICtrlCreateListViewItem("line1|990.99|06", $search_LV) _GUICtrlListView_SetColumnWidth($search_LV, 0, 75) _GUICtrlListView_SetColumnWidth($search_LV, 1, 75) _GUICtrlListView_SetColumnWidth($search_LV, 2, 75) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ _GUICtrlListView_RegisterSortCallBack($search_LV, False) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $search_LV ; Kick off the sort callback ;~ _GUICtrlListView_SortItems($search_LV, GUICtrlGetState($search_LV)) ;~ _GUICtrlListView_UnRegisterSortCallBack($search_LV) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $search_LV ;~ If Not IsHWnd($search_LV) Then $hWndListView = GUICtrlGetHandle($search_LV) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom ;~ Case $search_LV Case GUICtrlGetHandle($search_LV) Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked ConsoleWrite("Header geklickt" & @CRLF) Local $tInfo = DllStructCreate($tagNMLISTVIEW, $iLparam) _GUICtrlListView_UnRegisterSortCallBack($search_LV) Local $ColumnSorted = DllStructGetData($tInfo, 'SubItem') If $ColumnSorted = 1 Then ConsoleWrite('Numeric: ' & _GUICtrlListView_RegisterSortCallBack($search_LV, True) & @CRLF) Else ConsoleWrite('Literal: ' & _GUICtrlListView_RegisterSortCallBack($search_LV, False) & @CRLF) EndIf _GUICtrlListView_SortItems($search_LV, DllStructGetData($tInfo, 'SubItem')) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY Ordering the "String" column, you notice that the line "line10" is not ordered last. And 'possible to order the "String" column in descending order? thank you very much
  4. Hi guys, I wonder if there is a way to sort the filelist in an array from _FileListToArray () when files have the regular Windows enumeration example: File1 (1), File2 (2), File3 (3), etc. I'm posting two sample graphics so you can see what I mean I would like to get my list like in graphic 2 right now I'm getting my list like in graphic 1 which is the something I don't like. It's worth to say that I have no problem with a list when the files's names start with a number or is just a number thanks to the code found in this post. But, the problem is still present if I just get rid of the parenthesis that is () so in other words the problem happens when the enumeration is at the end of the names whether parenthesis are present or not.
  5. I want to coding a excel sort,scheduling system. When I input orgin file,and choose times(example is 7 times(A -->G)) system will output excel. (rule: 1 time include 1 Name ,but Food can't Repeat. secend's Food can't overlap with previous) How to codng of it ?!!!! Thank you veryvery much!!!!!! test.xlsx
  6. Hi I'am trying to list files from folder sorted by name (same as the picture) i tried this code #include <File.au3> $arr = _FileListToArray("D:\2") _ArrayDisplay($arr) i am getting this result Any one could explain why it is putting 10-1 before 8-1 ? how can i make Autoit view file same as windows explorer ?
  7. Hi guys, I am using an old version of Excel.au3 which I am not ready to update yet so please help me. The old Excel.au3 does not have any method for SORT. I attempted to create one since i need one but I am getting an error. Here's my sample code: $oAppl.Activesheet.UsedRange.sort($oAppl.Activesheet.cells(1,5),1,1) I thought this would work but I get the : ==> The requested action with this object has failed.: $oAppl.Activesheet.UsedRange.sort($oAppl.Activesheet.cells(1,$BidDayColNumber),1,1) $oAppl.Activesheet.UsedRange.sort($oAppl.Activesheet.cells(1,$BidDayColNumber),1,1)^ ERROR Any ideas or alternatives on sorting a range without calling from Excel.au3?
  8. Hello all, Back again it seems. I've hit a snag in the below script. I use this on win 7 and XP machines frequently and have just realized that sorting using column headers is not 'working' (is not updating listview; it looks like something is going on behind the scenes..) when clicked. Also this does not show the sorting arrow when using the callback sort functionality. So, to sum up, I am not seeing the arrow keys when clicking the column header to sort. And, it is not sorting the values in the $List1 ListView box on a win XP machine. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <GUIListBox.au3> #include <GUIEdit.au3> #include <GuiListView.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <ScrollBarConstants.au3> #include <GuiScrollBars.au3> Local $List1, $List2, $List3, $List4, $GUIhandle Local $Button19, $Button91, $ButtonAZ, $ButtonZA Local $hChild_1, $cLabel_1, $cLabel_2, $cLabel_3 GUI() Repaint() Local $bSysMsg = False Local $aRect = _GUICtrlListView_GetItemRect($List1, 0) $iDeltaY = $aRect[3] - $aRect[1] _GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List2), $SB_BOTH, $ESB_DISABLE_BOTH) _GUIScrollBars_EnableScrollBar(ControlGetHandle("", "", $List3), $SB_BOTH, $ESB_DISABLE_BOTH) _GUICtrlListView_RegisterSortCallBack($List1) _GUICtrlListView_RegisterSortCallBack($List2) _GUICtrlListView_RegisterSortCallBack($List3) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND") While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $GUIhandle Switch $msg[0] Case $GUI_EVENT_CLOSE Quit() EndSwitch If $bSysMsg Then $bSysMsg = False _Resize_ListViews() EndIf Case $hChild_1 Switch $msg[0] Case $GUI_EVENT_CLOSE GUIDelete($hChild_1) EndSwitch EndSwitch WEnd Func Repaint() Local $L1, $L2, $L3 _GUICtrlListView_BeginUpdate($List1) _GUICtrlListView_DeleteAllItems($List1) _GUICtrlListView_BeginUpdate($List2) _GUICtrlListView_DeleteAllItems($List2) _GUICtrlListView_BeginUpdate($List3) _GUICtrlListView_DeleteAllItems($List3) For $Index = 0 To 10 Step 1 $L1 = _GUICtrlListView_AddItem($List1, $Index, $Index) $L2 = _GUICtrlListView_AddItem($List2, $Index, $Index) $L3 = _GUICtrlListView_AddItem($List3, $Index, $Index) Next _GUICtrlListView_SetColumnWidth($List1, 0, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($List2, 0, $LVSCW_AUTOSIZE) _GUICtrlListView_EndUpdate($List1) _GUICtrlListView_EndUpdate($List2) _GUICtrlListView_EndUpdate($List3) EndFunc ;==>Repaint Func Quit() _GUICtrlListView_UnRegisterSortCallBack($List1) _GUICtrlListView_UnRegisterSortCallBack($List2) _GUICtrlListView_UnRegisterSortCallBack($List3) Exit EndFunc ;==>Quit Func GUI() Local $Index, $LV1, $LV2, $LV3, $L1_EX, $L2_EX, $L3_EX $GUIhandle = GUICreate("ArchServer", 680, 575, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX) ;creates the parent window $List1 = _GUICtrlListView_Create($GUIhandle, "Computer Name ", 20, 35, 300, 448, -1, $LVS_EX_DOUBLEBUFFER) ;;$ES_READONLY incase you don't want to be able to select text $cLabel_1 = GUICtrlCreateLabel("", 20, 35, 300, 448) GUICtrlSetState($cLabel_1, $GUI_DISABLE) GUICtrlSetResizing($cLabel_1, $GUI_DOCKAUTO) GUICtrlSetBkColor($cLabel_1, $GUI_BKCOLOR_TRANSPARENT) _GUICtrlListView_SetExtendedListViewStyle($List1, $LVS_EX_TWOCLICKACTIVATE) $List2 = _GUICtrlListView_Create($GUIhandle, "Date/Time", 355, 35, 190, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB)) $cLabel_2 = GUICtrlCreateLabel("", 355, 35, 190, 450) GUICtrlSetState($cLabel_2, $GUI_DISABLE) GUICtrlSetResizing($cLabel_2, $GUI_DOCKAUTO) GUICtrlSetBkColor($cLabel_2, $GUI_BKCOLOR_TRANSPARENT) $List3 = _GUICtrlListView_Create($GUIhandle, "Speed", 574, 35, 95, 450, -1, BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FLATSB)) $cLabel_3 = GUICtrlCreateLabel("", 574, 35, 95, 450) GUICtrlSetState($cLabel_3, $GUI_DISABLE) GUICtrlSetResizing($cLabel_3, $GUI_DOCKAUTO) GUICtrlSetBkColor($cLabel_3, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateLabel("Additional Info", 20, 489) ;creates the label for $List4 GUICtrlSetResizing(-1, $GUI_DOCKSIZE) $List4 = GUICtrlCreateList("", 20, 512, 635, 40, BitOR($WS_BORDER, $WS_VSCROLL), $ES_READONLY) GUICtrlSetResizing($List4, $GUI_DOCKAUTO) GUICtrlCreateLabel("Active Connections: ", 525, 487) ;creates the label for the active connections GUICtrlSetResizing(-1, $GUI_DOCKSIZE) $ActiveConnections = GUICtrlCreateList("0", 625, 486, 30, 30) ;dynamically updating list of connections as they come in GUICtrlSetResizing($ActiveConnections, $GUI_DOCKSIZE) GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUISetState(@SW_SHOW) ;shows the GUI window For $Index = 0 To 10 Step 1 $LV1 = _GUICtrlListView_AddItem($List1, " ") ;adds a default value into $List1 $LV2 = _GUICtrlListView_AddItem($List2, " ") ;adds a default value into $List2 $LV3 = _GUICtrlListView_AddItem($List3, " ") ;adds a default value into $List3 Next EndFunc ;==>GUI Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, _ $ceLines, $cl $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Local Const $iLines = _SendMessage($List1, $LVM_GETTOPINDEX) - _SendMessage($List2, $LVM_GETTOPINDEX) _SendMessage($List2, $LVM_SCROLL, 0, $iLines * $iDeltaY) _SendMessage($List3, $LVM_SCROLL, 0, $iLines * $iDeltaY) Switch $hWndFrom Case $List1 Switch $iCode Case $LVN_COLUMNCLICK _GUICtrlListView_SortItems($List1, GUICtrlGetState($List1)) Case $NM_CLICK $sData = _GUICtrlListView_GetSelectedIndices($List1) _GUICtrlListView_SetItemSelected($List2, $sData, True, False) _GUICtrlListView_SetItemSelected($List3, $sData, True, False) EndSwitch Case $List2 Switch $iCode Case $LVN_COLUMNCLICK _GUICtrlListView_SortItems($List1, GUICtrlGetState($List1)) Case $NM_CLICK $sData = _GUICtrlListView_GetSelectedIndices($List2) _GUICtrlListView_SetItemSelected($List1, $sData, True, False) _GUICtrlListView_SetItemSelected($List3, $sData, True, False) EndSwitch Case $List3 Switch $iCode Case $LVN_COLUMNCLICK _GUICtrlListView_SortItems($List1, GUICtrlGetState($List1)) Case $NM_CLICK $sData = _GUICtrlListView_GetSelectedIndices($List3) _GUICtrlListView_SetItemSelected($List1, $sData, True, False) _GUICtrlListView_SetItemSelected($List2, $sData, True, False) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY Func WM_SIZE($hWnd, $msg, $wParam, $lParam) _Resize_ListViews() Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func _WM_SYSCOMMAND($hWnd, $msg, $wParam, $lParam) Const $SC_MAXIMIZE = 0xF030 Const $SC_RESTORE = 0xF120 Switch $wParam Case $SC_MAXIMIZE, $SC_RESTORE $bSysMsg = True EndSwitch EndFunc ;==>_WM_SYSCOMMAND Func _Resize_ListViews() $aRet = ControlGetPos($GUIhandle, "", $cLabel_1) WinMove($List1, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3]) $aRet = ControlGetPos($GUIhandle, "", $cLabel_2) WinMove($List2, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3]) $aRet = ControlGetPos($GUIhandle, "", $cLabel_3) WinMove($List3, "", $aRet[0], $aRet[1], $aRet[2], $aRet[3]) EndFunc ;==>_Resize_ListViews ;========RESIZE FUNCTIONALITY THANKS TO MELBA All replies are much appreciated!
  9. Hi, just a short question. I 've got a lisitview with a few columns and I want to register a different sort for two kinds of columns. I 've got a solution, but I don't think it is a good one. Example : Col A = Names (Strings) Col B = Age (Integers) Right now I'm doing this: 1. _GUICtrlListView_RegisterSortCallBack 2. In my WM_NOTIFY Case GUICtrlGetHandle($search_LV) Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked Local $tInfo = DllStructCreate($tagNMLISTVIEW, $iLparam) ; Kick off the sort callback ;~ ConsoleWrite('SEARCH_LV Column geklickt' & @LF) ConsoleWrite("Sort: " & DllStructGetData($tInfo, 'SubItem')) If $ColumnSorted <> DllStructGetData($tInfo, 'SubItem') Then _GUICtrlListView_UnRegisterSortCallBack($search_LV) ConsoleWrite('NEU' & @CRLF) EndIf $ColumnSorted = DllStructGetData($tInfo, 'SubItem') If DllStructGetData($tInfo, 'SubItem') = 9 Or DllStructGetData($tInfo, 'SubItem') = 10 Then ConsoleWrite('True: ' & _GUICtrlListView_RegisterSortCallBack($search_LV, True) & @CRLF) Else ConsoleWrite('False ' & _GUICtrlListView_RegisterSortCallBack($search_LV, False) & @CRLF) EndIf _GUICtrlListView_SortItems($search_LV, DllStructGetData($tInfo, 'SubItem')) So, I store the column clicked in a global variable. If the column is clicked again (sort asc or desc) then all is fine, if another column then the one before is clicked, I unregister the callback and create a new one. The new callback (in the if) depends on the column clicked because of the content to sort (strings or numbers). Is there an easier / better way? Do I have to use my own sorting function with GuiCtrlRegisterListViewSort? Edit: It still doesn't work in every case (just noticed). Thanks Mega
  10. I have a list view (first two colums are Name and Surname). Now I want to sort the items by alphabet. It should sort the names from A to Z and if the Name is teh shame it should sort it by the surname, too. I know about the _GUICtrlListView_SimpleSort() Function, but that only sorts one column. My problem is, that I want to save a value with the number in the list view (first is number one, second is number two...) in a file so when I need to retreive that value I search for the number of the item in the file. Thank you!
  11. I recently managed to make a ListView sort correctly by clicking on it's columns, it does sort items very well but there's a very annoying thing >_< : every time after the items are sorted out, an item gets focused ! After I click a column, one item gets blue'd, like when its selected, even if its not ! Note that this happens only becuase of this function : _GUICtrlListView_SimpleSort Instead, the _GUICtrlListView_SortItems function is not doing this , but because of my luck,I must use _GUICtrlListView_SimpleSort ( but it is faster ) Here's my script to test to see what I mean: #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> $Form1 = GUICreate("Form1", 383, 307, 192, 124) $ListView1 = GUICtrlCreateListView("C1|C2|C3", 56, 16, 257, 241) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) $ListView1_0 = GUICtrlCreateListViewItem("1|5|6", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("2|7|8", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("3|9|10", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("4|11|12", $ListView1) GUISetState(@SW_SHOW) Global $toggle = 1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ListView1 _GUICtrlListView_SimpleSort($ListView1, $toggle, GUICtrlGetState($ListView1)) EndSwitch WEnd How could I get rid of this item focus ?
  12. How can I do to, when I click on on a specific column in a listview control, instead to get clicked/sorted other column. Is this possible ? I already know how to sort a column when I click on it : after the listview control was created, I add this code : _GUICtrlListView_RegisterSortCallBack(-1) I know that a gui can wait for a window event to happen, like a click on a control, but how can this be done to look if I clicked on a specific column and if so then, to sort (a clasic sort ) other column instead o.O ?
  13. I have a ListView that is created from a FileRead() using delimiters and then added into the ListView as shown below. Local $src = InetGet($url, $file, 1) $data = FileRead($file) $array = StringSplit($data, ";", 1) FileDelete($file) For $n = 1 To UBound($array) - 1 Step 3 $iItem = _GUICtrlListView_AddItem($ListView, $array[$n]) $a = UBound($array) - 1 If $n + 1 > $a Then ExitLoop Else _GUICtrlListView_AddSubItem($ListView, $iItem, $array[$n + 1], 1) _GUICtrlListView_AddSubItem($ListView, $iItem, $array[$n + 2], 2) EndIf Next $PlayerCount = _GUICtrlListView_GetItemCount($ListView) _GUICtrlListView_SetColumn($ListView, 0, "Name (Online: " & $Count & ")") I was using _GUICtrlListView_SortItems to sort them and it appears to work correctly in that it adds the up and down arrow to the column but nothing moves. I tried another one that involved using DLL's but that didn't work either. Am I missing something or what?