Jump to content

BjornA

Members
  • Posts

    4
  • Joined

  • Last visited

BjornA's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thank you ! I was just looking for this function in AutoIt
  2. Thank you - I think I will just file it under "would be nice to know" instead of "need to know" Björn
  3. Dear Melba23, Thank you for the help, that is very good news. I'm not quite sure I understand why putting it outside the message handler improves the speed of the routine though. Do you know? all the best / Björn
  4. Dear All, The program below registers all files in the directory of "_New revised text" when this is on M: or N:. It then creates a database of the filenames and some other things and this works ok and is fairly fast. When I try to sort the database it doesn't however. If I am using Listview / Simplesort for a short list it works ok, but when using it for a longer list (approx 300 rows with 5 columns) it sorts very slowly, it takes just under 10 seconds to sort it. Is this normal or am I missing something? (I have tried using Autohotkey for a similar task and it sorts it almost instantenously so apparently it can be done, but I would prefer using AutoIt) ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiListView.au3> #include <GuiButton.au3> #include <Array.au3> Opt('MustDeclareVars', 1) global $aRec[1000][4] global $hWin, $hList, $B_DESCENDING global $CurrRec global $hBtnAccess CreateWin() Getdata() RunProgram() ;******************************************************************************************* func GetData() local $aAllDrives = DriveGetDrive("ALL") Local $search, $MyDir, $MyFile, $Au, $Size, $FullName, $Access, $FirstPos For $i = 1 to $aAllDrives[0] if StringInStr("M: N: ", $aAllDrives[$i])>0 then $search = FileFindFirstFile( $aAllDrives[$i] & "\*") if @error then exitloop while 1 $MyDir = FileFindNextFile($search) if @error then exitloop if @extended=1 then ; 1 = directory if $MyDir="_New revised text" then FileClose($search) $search=FileFindFirstFile( $aAllDrives[$i] &"\"& $MyDir & "\*.txt") while 1 $MyFile=FileFindNextFile($search) if @error then exitloop $FirstPos=StringInStr( $MyFile,"- ") if $FirstPos>1 then $Au=StringMid($MyFile,$Firstpos+2) $Au=StringMid($Au,1,StringLen($Au)-4) $Size=int(FileGetSize($aAllDrives[$i] &"\"& $MyDir &"\"& $MyFile)/1024) $FullName=$aAllDrives[$i] &"\"& $MyDir &"\"& $MyFile $Access=FileGetTime($FullName, 0, 1) GUICtrlCreateListViewItem($Au&"|"&$MyFile&"|"&$Size&"|"&$FullName&"|"&$Access,$hList) endif wend endif endif wend endif next GUISetState() Return endfunc func CreateWin() MsgBox(1,"","createwin") $hWin= GUICreate ( "Getting author name" , 500, 300, -1, -1, $WS_MINIMIZEBOX+$WS_SIZEBOX ) $hList=GUICtrlCreateListView ("Author name|File name|Size|Total name|Access", 10,10,480,250) _GUICtrlListView_SetItemCount($hList, 1005) _GUICtrlListView_SetColumnWidth($hList, 0, 130) _GUICtrlListView_SetColumnWidth($hList, 1, 270) _GUICtrlListView_SetColumnWidth($hList, 2, 50) _GUICtrlListView_SetColumnWidth($hList, 3, 50) _GUICtrlListView_SetColumnWidth($hList, 4, 100) GUICtrlSetResizing($hList,$GUI_DOCKAUTO) endfunc func RunProgram() Local $msg Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hList)] GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GuiSetState(@SW_SHOW) while 1 $msg=GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then ExitLoop wend GUIDELETE($hWin) endfunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) ; someone else's code ! #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndList, $tInfo Local $selectedRow $hWndList = $hList If Not IsHWnd($hList) Then $hWndList = GUICtrlGetHandle($hList) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") If ($hWndFrom = $hWndList) Then If ($iCode = $LVN_COLUMNCLICK) Then $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) _GUICtrlListView_SimpleSort($hWndList, $B_DESCENDING, DllStructGetData($tInfo, "SubItem")) ElseIf ($iCode = $NM_DBLCLK) Then $selectedRow = _GUICtrlListView_GetSelectionMark($hList) Run(@WindowsDir & "\notepad.exe " & _GUICtrlListView_GetItemText($hList, $selectedRow, 3), "") EndIf EndIf EndFunc I would be grateful for any help / Björn
×
×
  • Create New...