Rick Posted November 19, 2005 Author Posted November 19, 2005 Ok, I'm stuck again! How do i find the string of the files thats been selected, so i can then act on them? Who needs puzzles when we have AutoIt!!
ReFran Posted November 19, 2005 Posted November 19, 2005 (edited) Ok, I'm stuck again! How do i find the string of the files thats been selected, so i can then act on them?Have a look the "AutoIt UDFs Help". Under "_GUICtrlListViewGetItemText " you will find an example for that what you are looking for (Get Selected).HTH, Reinhard Edited November 19, 2005 by ReFran
Rick Posted November 20, 2005 Author Posted November 20, 2005 (edited) ok, everythings working fine, but how can i get it sort on loading of a particular column?? I've looked at the help files, but it doesnt seem obvious Edited November 20, 2005 by Rick Who needs puzzles when we have AutoIt!!
GaryFrost Posted November 20, 2005 Posted November 20, 2005 (edited) expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> opt('MustDeclareVars', 1) Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index, $Main_GUI Global $select_all = 0 HotKeySet("^a", "_SetSelectAll"); Ctrl+a Toggles selectin all ; Ctrl + Click selects multple items or Shift + Click $Main_GUI = GUICreate("Files", 392, 322) $listview = GUICtrlCreateListView("File|Size|Type|Date Created|Date Modified", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) _GUICtrlListViewSetColumnWidth ($listview, 0, 75) _GUICtrlListViewSetColumnWidth ($listview, 1, 75) _GUICtrlListViewSetColumnWidth ($listview, 2, 75) _GUICtrlListViewSetColumnWidth ($listview, 3, 75) _GUICtrlListViewSetColumnWidth ($listview, 4, 75) $Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30) GUISetState() GUISetState(@SW_LOCK) _PopulateListView($listview) Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ] _GUICtrlListViewSort ($listview, $B_DESCENDING, 2); let's sort on type GUISetState(@SW_UNLOCK) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop Case $msg = $listview ; sort the list by the column header clicked on _GUICtrlListViewSort ($listview, $B_DESCENDING, GUICtrlGetState($listview)) Case Else ConsoleWrite($select_all & @LF) If $select_all = 1 Then _GUICtrlListViewSetItemSelState ($listview, -1) ElseIf $select_all = 2 Then _GUICtrlListViewSetItemSelState ($listview, -1, 0) $select_all = 0 EndIf EndSelect WEnd Exit Func _PopulateListView(ByRef $listview) Local $startdir, $var, $search, $file, $item, $attrib, $time $startdir = @MyDocumentsDir $var = FileSelectFolder("Choose a folder.", $startdir) If $var <> "" Then FileChangeDir($var) ; Shows the filenames of all files in the current directory. $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then Return EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $item = $file & "|" $attrib = FileGetAttrib($file) If Not @error Then If StringInStr($attrib, "D") Then $item = $file & "||Directory|" Else $item = $file & "|" & FileGetSize($file) & " bytes" & "|File|" EndIf EndIf $time = FileGetTime($file, 1) If Not @error Then $item = $item & $time[0] & "/" & $time[1] & "/" & $time[2] & " " If Int($time[3]) > 12 Then $item = $item & $time[3] - 12 & ":" & $time[4] & " PM|" Else $item = $item & $time[3] & ":" & $time[4] & " AM|" EndIf EndIf $time = FileGetTime($file) If Not @error Then $item = $item & $time[0] & "/" & $time[1] & "/" & $time[2] & " " If Int($time[3]) > 12 Then $item = $item & $time[3] - 12 & ":" & $time[4] & " PM" Else $item = $item & $time[3] & ":" & $time[4] & " AM" EndIf EndIf GUICtrlCreateListViewItem($item, $listview) WEnd ; Close the search handle FileClose($search) EndIf EndFunc ;==>_PopulateListView Func _SetSelectAll() If $select_all = 0 Then $select_all = 1 ElseIf $select_all = 1 Then $select_all = 2 EndIf EndFunc ;==>_SetSelectAll Edited November 20, 2005 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.
Rick Posted November 20, 2005 Author Posted November 20, 2005 Thanks, youre a star Who needs puzzles when we have AutoIt!!
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