Rahul Rohela Posted June 23, 2006 Author Posted June 23, 2006 @ Rahul Rohela : it does work on XP with autoit-v3.1.1.127 and v1.63 GuiListView.au3 + bugfixes on my end.I cannot test it on Windows 2000 prof here ... Let's see if someone can... ? Gafrost ?Checked on other WIN2000 Prof systems too its not working,,,
GaryFrost Posted June 23, 2006 Posted June 23, 2006 (edited) No longer have access to anything other than WinXP Pro SP2, but the code should work on 2kMinimum operating systems Windows NT 3.51, Windows 95 Edited June 23, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
randallc Posted July 1, 2006 Posted July 1, 2006 (edited) Hi, This avoids many usual calls to ListView and therefore might work on Win2K? Also the algorithm means it works in 2 secs instead of 4 mins. Best, Randallc expandcollapse popup;compare2GUIs.au3 0_4 #include <GUIConstants.au3> ;#include <GuiListView.au3> ;#include "Array2D.au3" #include "_GUICtrlListViewMulti.au3" ;#include "_GUICtrlListView.au3" GUICreate("listview items", 460, 350, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF); will change background color $timerstampS=TimerInit() $listviewA = _GUICtrlCreateListView("col1 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) For $x = 1 To 1000 _GUICtrlCreateListViewItem("item" & $x, $listviewA) Next _GUIListViewReDim($listviewA,1) GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping $listviewB = _GUICtrlCreateListView("col2 ", 10, 180, 200, 150);,$LVS_SORTDESCENDING) $itemB1 = _GUICtrlCreateListViewItem("item2", $listviewB) $itemB2 = _GUICtrlCreateListViewItem("item1", $listviewB) $itemB3 = _GUICtrlCreateListViewItem("item3", $listviewB) For $x = 4 To 100 _GUICtrlCreateListViewItem("item" & $x, $listviewB) Next _GUIListViewReDim($listviewB,1) ConsoleWrite("START :"&round(TimerDiff($timerstampS)) & " mseconds "&@lf) $listviewC = _GUICtrlCreateListView("col3 ", 220, 10, 200, 150);,$LVS_SORTDESCENDING) $btn_compare = GUICtrlCreateButton("Compare", 260, 190, 120, 25) GUISetState() Do $msg = GUIGetMsg() Select Case $msg = $btn_compare $timerstampL=TimerInit() __GUICtrlListViewSort($listviewA,-1,0) __GUICtrlListViewSort($listviewB,-1,0,1) $i_counter = 0 For $x = 0 To __GUICtrlListViewGetItemCount($listviewA) - 1 $found = False $s_item1 = __GUICtrlListViewGetItemText($listviewA, $x, 0) For $y = $i_counter To __GUICtrlListViewGetItemCount($listviewB) - 1 $s_item2 = __GUICtrlListViewGetItemText($listviewB, $y, 0) If StringUpper($s_item1) = StringUpper($s_item2) Then $i_counter = $y+1 $found = True ExitLoop ElseIf StringUpper($s_item1) < StringUpper($s_item2) Then $i_counter = $y ExitLoop EndIf Next If Not $found Then _GUICtrlCreateListViewItem($s_item1, $listviewC) Next _GUIListViewReDim($listviewC,1) ConsoleWrite("Create :"&round(TimerDiff($timerstampL)) & " mseconds "&@lf) MsgBox(0,"","_GUICtrlListViewGetItemCount ($listviewC)="&_GUICtrlListViewGetItemCount($listviewC)) ;~ Case $msg = $listviewA ;~ ;MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listviewA), 2) ;~ __GUICtrlListViewSort($listviewA,-1,0) ;~ Case $msg = $listviewB ;~ ;MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listviewB), 2) ;~ __GUICtrlListViewSort($listviewB,-1,0) ;~ Case $msg = $listviewC ;~ MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listviewC), 2) ;~ __GUICtrlListViewSort($listviewC,-1,0) EndSelect Until $msg = $GUI_EVENT_CLOSE [PS the special "include" messes up ListView selection, after, though] Edited July 1, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted July 1, 2006 Posted July 1, 2006 (edited) Hi, The algorithm alone changes the time by 20x, using inbuilt GUILIstView in WinXP; Best, Randallc expandcollapse popup;compare2GUIs.au3 0_2 #include <GUIConstants.au3> #include <GuiListView.au3> GUICreate("listview items", 460, 350, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF); will change background color $listviewA = GUICtrlCreateListView("col1 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) $itemA1 = GUICtrlCreateListViewItem("..item2", $listviewA) For $x = 2 To 1000 GUICtrlCreateListViewItem("item" & $x, $listviewA) Next GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping $listviewB = GUICtrlCreateListView("col2 ", 10, 180, 200, 150);,$LVS_SORTDESCENDING) $itemB1 = GUICtrlCreateListViewItem("..item2", $listviewB) $itemB2 = GUICtrlCreateListViewItem("item1", $listviewB) $itemB3 = GUICtrlCreateListViewItem("item3", $listviewB) For $x = 4 To 100 GUICtrlCreateListViewItem("item" & $x, $listviewB) Next $listviewC = GUICtrlCreateListView("col3 ", 220, 10, 200, 150);,$LVS_SORTDESCENDING) $btn_compare = GUICtrlCreateButton("Compare", 260, 190, 120, 25) GUISetState() Dim $B_DESCENDINGA[_GUICtrlListViewGetSubItemsCount ($listviewA) ] Dim $B_DESCENDINGB[_GUICtrlListViewGetSubItemsCount ($listviewB) ] Do $msg = GUIGetMsg() Select Case $msg = $btn_compare $timerstampL=TimerInit() _GUICtrlListViewSort($listviewA,$B_DESCENDINGA,0) _GUICtrlListViewSort($listviewB,$B_DESCENDINGB,0) $i_counter = 0 For $x = 0 To _GUICtrlListViewGetItemCount($listviewA) - 1 $found = False $s_item1 = _GUICtrlListViewGetItemText($listviewA, $x, 0) For $y = $i_counter To _GUICtrlListViewGetItemCount($listviewB) - 1 $s_item2 = _GUICtrlListViewGetItemText($listviewB, $y, 0) If StringUpper($s_item1) = StringUpper($s_item2) Then $i_counter = $y+1 $found = True ExitLoop ElseIf StringUpper($s_item1) < StringUpper($s_item2) Then $i_counter = $y ExitLoop EndIf Next If Not $found Then GUICtrlCreateListViewItem($s_item1, $listviewC) EndIf Next Dim $B_DESCENDINGC[_GUICtrlListViewGetSubItemsCount ($listviewC) ] ConsoleWrite("Create :"&round(TimerDiff($timerstampL)) & " mseconds "&@lf) MsgBox(0,"","_GUICtrlListViewGetItemCount ($listviewC)="&_GUICtrlListViewGetItemCount($listviewC)) Case $msg = $listviewA _GUICtrlListViewSort($listviewA,$B_DESCENDINGA,0) Case $msg = $listviewB _GUICtrlListViewSort($listviewB,$B_DESCENDINGB,0) Case $msg = $listviewC _GUICtrlListViewSort($listviewC,$B_DESCENDINGC,0) EndSelect Until $msg = $GUI_EVENT_CLOSE Edited July 1, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted July 1, 2006 Posted July 1, 2006 (edited) On WinXP,(? not 2K?) Nearly the same speed if just one ListView accelerated, using my usual _GUICtrlListView.au3; [without messing up GUIListView selection] expandcollapse popup;compare2GUIs.au3 0_4 #include <GUIConstants.au3> #include <GuiListView.au3> #include "_GUICtrlListView.au3" GUICreate("listview items", 460, 350, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF); will change background color $timerstampS=TimerInit() $listviewA = _GUICtrlCreateListView("col1 ", 10, 10, 200, 150);,$LVS_SORTDESCENDING) $itemA1 = _GUICtrlCreateListViewItem("...item2", $listviewA) For $x = 2 To 1000 _GUICtrlCreateListViewItem("item" & $x, $listviewA) Next _GUIListViewReDim() GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping $listviewB = GUICtrlCreateListView("col2 ", 10, 180, 200, 150);,$LVS_SORTDESCENDING) $itemB1 = GUICtrlCreateListViewItem("...item2", $listviewB) $itemB2 = GUICtrlCreateListViewItem("item1", $listviewB) $itemB3 = GUICtrlCreateListViewItem("item3", $listviewB) For $x = 4 To 100 GUICtrlCreateListViewItem("item" & $x, $listviewB) Next ConsoleWrite("START :"&round(TimerDiff($timerstampS)) & " mseconds "&@lf) $listviewC = GUICtrlCreateListView("col3 ", 220, 10, 200, 150);,$LVS_SORTDESCENDING) $btn_compare = GUICtrlCreateButton("Compare", 260, 190, 120, 25) GUISetState() Dim $B_DESCENDINGA[_GUICtrlListViewGetSubItemsCount ($listviewA) ] Dim $B_DESCENDINGB[_GUICtrlListViewGetSubItemsCount ($listviewB) ] Do $msg = GUIGetMsg() Select Case $msg = $btn_compare $timerstampL=TimerInit() __GUICtrlListViewSort($listviewA,$B_DESCENDINGA,0) _GUICtrlListViewSort($listviewB,$B_DESCENDINGB,0) $i_counter = 0 _GUICtrlListViewSetItemCount($listviewC, $listviewA) For $x = 0 To __GUICtrlListViewGetItemCount($listviewA) - 1 $found = False $s_item1 = __GUICtrlListViewGetItemText($listviewA, $x, 0) For $y = $i_counter To _GUICtrlListViewGetItemCount($listviewB) - 1 $s_item2 = _GUICtrlListViewGetItemText($listviewB, $y, 0) If StringUpper($s_item1) = StringUpper($s_item2) Then $i_counter = $y+1 $found = True ExitLoop ElseIf StringUpper($s_item1) < StringUpper($s_item2) Then $i_counter = $y ExitLoop EndIf Next If Not $found Then GUICtrlCreateListViewItem($s_item1, $listviewC) Next ConsoleWrite("Create :"&round(TimerDiff($timerstampL)) & " mseconds "&@lf) MsgBox(0,"","_GUICtrlListViewGetItemCount ($listviewC)="&_GUICtrlListViewGetItemCount($listviewC)) Dim $B_DESCENDINGC[_GUICtrlListViewGetSubItemsCount ($listviewC) ] Case $msg = $listviewA __GUICtrlListViewSort($listviewA,$B_DESCENDINGA,0) Case $msg = $listviewB _GUICtrlListViewSort($listviewB,$B_DESCENDINGB,0) Case $msg = $listviewC _GUICtrlListViewSort($listviewC,$B_DESCENDINGC,0) EndSelect Until $msg = $GUI_EVENT_CLOSERandall Edited July 1, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted July 2, 2006 Posted July 2, 2006 (edited) BTW - I have found a Win2K machine, and they ALL work on it! [at least on 126beta and on 128beta] - so it was probably just not getting the correct syntax on the 127 version (where item had to be enumerated in Get calls) that was the problem, rather than the windows version randallc Edited July 2, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Rahul Rohela Posted July 7, 2006 Author Posted July 7, 2006 BTW - I have found a Win2K machine, and they ALL work on it! [at least on 126beta and on 128beta] - so it was probably just not getting the correct syntax on the 127 version (where item had to be enumerated in Get calls) that was the problem, rather than the windows version randallc Thx for your Script & logic.. Your List view is lightning fast...
randallc Posted July 7, 2006 Posted July 7, 2006 (edited) Hi, Here is one way; i had to make some corrections in "refresh" to read from the corect end of the binary record too; Make a hidden index column, then compare it later; [and re-sort on the index col at the end..] expandcollapse popup;ListViewDupes7.au3 0_14 #include "_GUICtrlListView.au3" $time1 = _NowTime(3) GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES) GUISetBkColor (0x00E0FFFF); will change background color $lable = GUICtrlCreateLabel ( "",-1,200, 200) $lable1 = GUICtrlCreateLabel ( "",-1,220, 200) $listview = _GuiCtrlCreateListView ("col1 |col2|col3|Index ",10,10,200,150);,$LVS_SORTDESCENDING) global $i_IndexColumn=3 _GUICtrlListViewHideColumn($listview,$i_IndexColumn) $button = GuiCtrlCreateButton ("Value?",75,170,70,20) GuiCtrlSetState(-1,$GUI_DROPACCEPTED); to allow drag and dropping GuiSetState() $timerstamp0=TimerInit() _LockAndWait3() For $aa = 0 To 2599 _GUICtrlCreateListViewItem("item" & Mod($aa, 100) + 1&"|||"&$aa+1, $listview) ; a lot of dupes ;~ _GUICtrlCreateListViewItem("item" & $aa&"|||"&$aa, $listview) ; zero dupes Next _GUICtrlListViewHideColumn($listview,$i_IndexColumn) _ResetLockWait3() ConsoleWrite("Create :"&round(TimerDiff($timerstamp0)) & " mseconds "&@lf) Do $msg = GuiGetMsg () Select Case $msg = $button _deleteduplicate() Case $msg = $listview if GUICtrlGetState($listview)=0 then __GUICtrlListViewSort($listview,-1, GUICtrlGetState($listview)) if GUICtrlGetState($listview)<>0 then MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2) ;MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2) EndSelect Until $msg = $GUI_EVENT_CLOSE Func _deleteduplicate() $time1 = _NowTime(3) local $ar_Avoid[1], $s_Bin $timerstamp1=TimerInit() __GUICtrlListViewSort($listview,$B_Descending, 0);,3) $count = __GUICtrlListViewGetItemCount($listview) GUICtrlSetData($lable1, $count) For $x =$count - 1 To 0 step -1 $Itemtxt1 = __GUICtrlListViewGetItemText($listview, $x, 0);,"listview items") $Itemtxt1Index = Number(__GUICtrlListViewGetItemText($listview, $x, $i_IndexColumn));,"listview items") $s_BinTemp="1" do if $x>0 then $Itemtxt2 = __GUICtrlListViewGetItemText($listview, $x- 1 , 0);,"listview items") $Itemtxt2Index = Number(__GUICtrlListViewGetItemText($listview, $x-1, $i_IndexColumn));,"listview items") If StringUpper($Itemtxt1) == StringUpper ($Itemtxt2) Then $s_BinTemp&="0" If $Itemtxt2Index < $Itemtxt1Index Then ;change item if index number smallest $Itemtxt1Index = $Itemtxt2Index $s_StringTrimRight=StringTrimRight($s_BinTemp,1) $s_BinTemp=StringReplace($s_StringTrimRight,"1","0")&"1" EndIf $count -= 1 $x -= 1 EndIf EndIf until StringUpper($Itemtxt1) <> StringUpper ($Itemtxt2) or $x=0 $s_Bin&=$s_BinTemp Next GUICtrlSetData($lable, "X is " & $x & " New count " & $count) ConsoleWrite("b4refresh :"&round(TimerDiff($timerstamp1)) & " mseconds "&@lf) _refreshArray($s_Bin) ConsoleWrite("_FirstList :"&round(TimerDiff($timerstamp1)) & " mseconds "&@lf) MsgBox(0, "time", "_FirstList :"&round(TimerDiff($timerstamp1)) & " mseconds ") ;MsgBox(0, "time", "First time " & $time1 & " Second time " & _NowTime(3)) EndFunc ;==>_deleteduplicate5 Func _refreshArray(byref $s_Binary) local $a $ar_Temp=$ar_LISTVIEWArray _LockAndWait3() $ar_count=StringSplit($s_Binary,"1") $i_Count=UBound($ar_count)-2 __GUICtrlListViewDeleteAllItems($listview) for $b=StringLen($s_Binary) to 1 step -1 if Stringmid($s_Binary,$b,1)=="1" Then _GUICtrlCreateListViewItem($ar_Temp[UBound($ar_Temp)-$b],$listview) EndIf next _ResetLockWait3() _GUICtrlListViewHideColumn($listview,$i_IndexColumn) _GUIListViewReDim() __GUICtrlListViewSort($listview,-1, $i_IndexColumn) EndFunc ;==>_refreshArray5Best, Randallc Edited July 7, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted July 10, 2006 Posted July 10, 2006 (edited) Hi, Now even faster; can you please test run the dupes8 for me?; needs _GUIctrlListview.au3 0_97 from sig link. [sorry wrong thread] Edited July 10, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted July 17, 2006 Posted July 17, 2006 (edited) Hi, I have attempted adding the delete by compare udfs; 2 main new funcs; see if it makes it easier (118 version of GUICtrlListView.au3 from my sig) Best, Randall expandcollapse popup;compare2GUIsAr.au3 0_12 #include "_GUICtrlListView.au3" ;~ #include "Array2D.au3" GUICreate("listview items", 460, 350, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF); will change background color $timerstampS=TimerInit() local $i_PrevCompare,$i_PrevLV,$i_Quick=0 if not UBound($ar_LISTVIEWArray)-1<4000 and not $GUICtrlSetImage and not $i_GUISetCheckBoxes then $i_Quick=1 $listviewA = _GUICtrlCreateListViewIndexed("col1 ", 10, 10, 200, 150) ;================================================================================= For $x = 1 To 1000 _GUICtrlCreateListViewItem("item" & $x, $listviewA,-1,$i_Quick,1) Next GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping $ar_listviewA=_ListViewGetTextArray($listviewA ,1); sorted on Col1 base 1 ;================================================================================= $listviewB = _GUICtrlCreateListView("mt|col2 ", 10, 180, 200, 150) For $x = 1 To 100 _GUICtrlCreateListViewItem("|item" & $x, $listviewB,-1,$i_Quick) Next $ar_listviewB=_ListViewGetTextArray($listviewB ,2); sorted on Col2 base 1 ;================================================================================= $listviewC = _GUICtrlCreateListViewIndexed("col3 ", 220, 10, 200, 150,$LVS_SORTASCENDING) $btn_compare = GUICtrlCreateButton("Compare", 260, 190, 120, 25) GUISetState() ConsoleWrite("START :"&round(TimerDiff($timerstampS)) & " mseconds "&@lf) ;================================================================================= Do $msg = GUIGetMsg() Select Case $msg = $btn_compare if not $i_PrevCompare then $timerstampL=TimerInit() _CreateLVCompare2($listviewC,$ar_listviewA,0,$ar_listviewB,1,$i_Quick); Col "0" of LV_A, Col "1" of LV_B ConsoleWrite("CreateC :"&round(TimerDiff($timerstampL)) & " mseconds "&@lf) $ar_listviewC=_ListViewGetTextArray($listviewC ,1); sorted on Col1 base 1 MsgBox(0,"","Create :"&round(TimerDiff($timerstampL)) & " mseconds ") $i_PrevLV=$listviewC $i_PrevCompare=True EndIf Case $msg = $listviewA if $i_PrevLV<>$listviewA then _ListViewReDraw($listviewA,$ar_listviewA,$i_Quick) __GUICtrlListViewSort($listviewA,-1,GUICtrlGetState($listviewA));,2); $i_PrevLV=$listviewA Case $msg = $listviewB if $i_PrevLV<>$listviewB then _ListViewReDraw($listviewB,$ar_listviewB,$i_Quick) __GUICtrlListViewSort($listviewB,-1,GUICtrlGetState($listviewB));, $i_PrevLV=$listviewB Case $msg = $listviewC if $i_PrevLV<>$listviewC then _ListViewReDraw($listviewC,$ar_listviewC,$i_Quick) __GUICtrlListViewSort($listviewC,-1,GUICtrlGetState($listviewC));, $i_PrevLV=$listviewC EndSelect Until $msg = $GUI_EVENT_CLOSE Edited July 17, 2006 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted July 18, 2006 Posted July 18, 2006 Slight update; in the zip at the GUICtrlListView link in my sig. Best, Randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now