How to arrange Listview items from latest to oldest
#1
Posted 06 April 2011 - 06:19 AM
15/06/2009|2:34:41 PM|2:34:41 PM|00:00:01| PC1 |10.110.5.21
16/06/2009|2:43:15 PM|2:43:18 PM|00:00:03| PC2 |10.110.5.22
21/06/2009|2:44:05 PM|2:44:09 PM|00:00:04| PC3 |10.110.5.23
30/06/2009|2:50:50 PM|2:50:51 PM|00:00:01| PC4 |10.110.5.24
01/07/2009|2:52:50 PM|2:53:26 PM|00:00:35| PC5 |10.110.5.25
10/07/2009|2:54:42 PM|2:55:08 PM|00:00:25| PC6 |10.110.5.26
#2
Posted 06 April 2011 - 06:47 AM
• AutoIt Version : 3.3.8.1/3.3.9.4 SciTE 3.3.0 Language:040C OS:WIN_7/ CPU:X64 OS:X64
- [Music] [2012-04-07] TinyChartsJukebox • [2012-07-28] TinyMp3Player • [2012-10-07] Mp3SearchEngine [2013-04-04] TinyMp3Downloader • [2012-11-05] TinyShoutCastTuner • [2012-11-01] BeepSongEditor
- [Upload] [2011-12-31] TinyFreeUploader • [2012-07-13] TinyPicCaptureUploader
- [Script Tools] [2012-10-03] SciTE Hopper • [2013-04-10] AutoIt&SciTEUpdater • [2012-12-21] TinyColorCatcher [2012-07-13] RegJumper • [2013-05-17] BinaryToAu3Kompressor • [2012-06-06] TinyAu3FilesSearch
- [Utilities] [2012-06-30] GetCommandLineParameters • [2011-12-21] TinyBackupBox • [2010-09-25] TinyBatteryBar [2011-12-05] TinyBrightnessControler • [2012-09-03] TinyUninstaller • [2012-07-01] TinyClipToSpeech • [2013-05-21] InternetShortcutCreator
- [Diverse] [2013-03-06] AnimatedSplash • [2013-01-18] GuiCtrlPicButton Simulate Reaction • [2012-04-15] CanYouRunIt
• Last updated Scripts and executables with full embedded files are available on : GoogleCode
#3
Posted 06 April 2011 - 07:01 AM
Try to convert each time part to YYYYMMDDHHMMSS time format and you could sort array by time !
hi wakillon. thanks for the tip. i'll give it a try.
#4
Posted 06 April 2011 - 11:59 PM
How to ask questions the smart way!
Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.
Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.
_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.
GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.
#5
Posted 07 April 2011 - 03:03 AM
here's a little try to solve or problem:
#include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <ListViewConstants.au3> #include <File.au3> ;#include <array.au3> Local $tZeit, $s1, $s2, $aFile $main = GUICreate("Lv-Sort", 600, 400) $listview1 = GUICtrlCreateListView("Date|Time Logged In|Last Responce|Idle|PC-No|IP|oCol", 10, 10, 590, 390, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) GUICtrlSetBkColor(-1, 0xE6E6FA) ; BackgrondColor odd _FileReadToArray(@ScriptDir & "\LVtoSort.TXT", $aFile) If Not @error Then For $i = 1 To $aFile[0] GUICtrlCreateListViewItem($aFile[$i] & "|" & $i, $listview1) GUICtrlSetBkColor(-1, 0xcccccc) ; BackgrondColor even Next EndIf _GUICtrlListView_SetColumnWidth($listview1, 0, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($listview1, 1, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($listview1, 2, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($listview1, 3, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($listview1, 4, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($listview1, 5, $LVSCW_AUTOSIZE) _GUICtrlListView_SetColumnWidth($listview1, 6, 0);This Column is the original Row-Nmber GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;<=========================================== Sortieren GUISetState() $first = True While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $listview1 If Not IsHWnd($listview1) Then $hWndListView = GUICtrlGetHandle($listview1) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ; Click on column _GUICtrlListView_BeginUpdate($listview1) Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) Local $iColNo = DllStructGetData($tInfo, "SubItem") $j = _GUICtrlListView_GetItemCount($listview1) $c = _GUICtrlListView_GetColumnCount($listview1) Local $aSortArray[$j] For $i = 0 To $j - 1 $aItem = _GUICtrlListView_GetItemTextArray($listview1, $i) Switch $iColNo Case 0,1 $aSplitDate = StringSplit($aItem[1], "/") $aSplitTime = _SplitTime($aItem[2]) $sToSort = $aSplitDate[3] & $aSplitDate[2] & $aSplitDate[1] & $aSplitTime[1] & $aSplitTime[2] & $aSplitTime[3] & "\|\" & $aItem[7] & "\|\" Case 2,3 $aSplitTime = _SplitTime($aItem[3]) $sToSort = $aItem[4] & "\|\" & $aItem[7] & "\|\" Case 4 $sToSort = $aItem[5] & "\|\" & $aItem[7] & "\|\" Case 5 $sToSort = $aItem[6] & "\|\" & $aItem[7] & "\|\" EndSwitch For $k = 1 To $c - 1 $sToSort &= $aItem[$k] If $k <> $c - 1 Then $sToSort &= "|" Next $aSortArray[$i] = $sToSort Next _arraySort($aSortArray) _GUICtrlListView_DeleteAllItems($listview1) For $i = 0 To $j - 1 $aTemp = StringSplit($aSortArray[$i],"\|\",1) GUICtrlCreateListViewItem($aTemp[3],$listview1) GUICtrlSetBkColor(-1, 0xcccccc) ; BackgrondColor even Next _GUICtrlListView_EndUpdate($listview1) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _SplitTime($sTime) ;2:34:41 PM Local $aTime = StringSplit($sTime, ":") $aTime[3] = StringReplace($aTime[3], " PM", "") If @extended > 0 Then $aTime[1] += 12 Return $aTime EndFunc ;==>_SplitTime
and here is the Test-File i worked with:
LVtoSort.Txt 366bytes
78 downloadsmfg autoBert
Edited by AutoBert, 07 April 2011 - 03:12 AM.
#6
Posted 07 April 2011 - 06:18 AM
Nice Try !
• AutoIt Version : 3.3.8.1/3.3.9.4 SciTE 3.3.0 Language:040C OS:WIN_7/ CPU:X64 OS:X64
- [Music] [2012-04-07] TinyChartsJukebox • [2012-07-28] TinyMp3Player • [2012-10-07] Mp3SearchEngine [2013-04-04] TinyMp3Downloader • [2012-11-05] TinyShoutCastTuner • [2012-11-01] BeepSongEditor
- [Upload] [2011-12-31] TinyFreeUploader • [2012-07-13] TinyPicCaptureUploader
- [Script Tools] [2012-10-03] SciTE Hopper • [2013-04-10] AutoIt&SciTEUpdater • [2012-12-21] TinyColorCatcher [2012-07-13] RegJumper • [2013-05-17] BinaryToAu3Kompressor • [2012-06-06] TinyAu3FilesSearch
- [Utilities] [2012-06-30] GetCommandLineParameters • [2011-12-21] TinyBackupBox • [2010-09-25] TinyBatteryBar [2011-12-05] TinyBrightnessControler • [2012-09-03] TinyUninstaller • [2012-07-01] TinyClipToSpeech • [2013-05-21] InternetShortcutCreator
- [Diverse] [2013-03-06] AnimatedSplash • [2013-01-18] GuiCtrlPicButton Simulate Reaction • [2012-04-15] CanYouRunIt
• Last updated Scripts and executables with full embedded files are available on : GoogleCode
#7
Posted 07 April 2011 - 08:26 AM
the entry into my text log is that it appends and goes into the last line. i wanted the listview to display the last line up to the first line from the text log which i am having trouble displaying it. i thought i will be able to do that using the register_sort_callback.
i have attached the textlog.
Attached Files
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users






