Rick Posted November 17, 2005 Share Posted November 17, 2005 I ask as I know the files i may or may not want to select, and the folder theyre in, but dont want a dropdown to other folders or buttons to other places. altho i do need the funtionality of ctrl A or ctrl click, sort by date etc. thanks for any help guys Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
Valuater Posted November 17, 2005 Share Posted November 17, 2005 1 are there any other folders inside the folder you want to look in? 2 are all the file types you want to find the same type ( .exe, or .doc or ???) need more info 8) Link to comment Share on other sites More sharing options...
Rick Posted November 17, 2005 Author Share Posted November 17, 2005 yes, they will be all of the same extension, altho there could be a few or hundreds of them and no, it only needs to look in one folder i like the FileOpenDialog function, but its too busy a screen for what i actually need thanks for any help Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
tonedeaf Posted November 17, 2005 Share Posted November 17, 2005 FileOpenDialog has an "init dir" parameter to open in on a specific folder Link to comment Share on other sites More sharing options...
Rick Posted November 17, 2005 Author Share Posted November 17, 2005 yes it does, altho what i dont want are all the left buttons for MyComputer, Desktop, neither do i require the dropdown box to select another folder as i know what folder i want to look in. this is all for a program i'm writing for others and i dont want to offer them more than. file selection, not folder selection all i'm looking for is a way to view a "specific" folder, see the files, sort by name/date, and optionaly select some or all Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
flyingboz Posted November 17, 2005 Share Posted November 17, 2005 all i'm looking for is a way to view a "specific" folder, see the files, sort by name/date, and optionaly select some or allwrite it yourself using the gui* functions, sounds like a listbox populated w/ directory contents will get you what you want.- You may also wish to research some old dllcall samples running around, DlgDirList or something along those lines, IIRC. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
Sokko Posted November 17, 2005 Share Posted November 17, 2005 (edited) Quite coincidentally, a program I'm working on right now uses an interface similar to what you want. I pried it out of the main script and made a quick example: #include <GUIConstants.au3> $gui = GUICreate("File Dropdown",200,100) $combo = GUICtrlCreateCombo("Select a file...",40,40,120,20,$CBS_DROPDOWNLIST) GUISetState(@SW_SHOW) $dir = InputBox("Directory?","Enter a directory to search (no trailing backslash)") $ext = InputBox("Extension?","Enter a file extension to search for (without the dot)") $search = FileFindFirstFile($dir&"\*."&$ext) While 1 $i = FileFindNextFile($search) If @error <> 0 Then ExitLoop $a = StringSplit($i,"\") $b = StringSplit($a[$a[0]],".") GUICtrlSetData($combo,$b[$b[0]-1]) WEnd FileClose($search) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd The stripping of the path and extension is only there because it saves screen real-estate. It's easy to remove if you're okay with super-wide dropdowns. PROBLEM: For some reason this dropdown doesn't show a scroll bar for large numbers of files, at least on my computer. Probably something to do with the styles. Edited November 17, 2005 by Sokko Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2005 Share Posted November 18, 2005 Quite coincidentally, a program I'm working on right now uses an interface similar to what you want. I pried it out of the main script and made a quick example: #include <GUIConstants.au3> $gui = GUICreate("File Dropdown",200,100) $combo = GUICtrlCreateCombo("Select a file...",40,40,120,20,$CBS_DROPDOWNLIST) GUISetState(@SW_SHOW) $dir = InputBox("Directory?","Enter a directory to search (no trailing backslash)") $ext = InputBox("Extension?","Enter a file extension to search for (without the dot)") $search = FileFindFirstFile($dir&"\*."&$ext) While 1 $i = FileFindNextFile($search) If @error <> 0 Then ExitLoop $a = StringSplit($i,"\") $b = StringSplit($a[$a[0]],".") GUICtrlSetData($combo,$b[$b[0]-1]) WEnd FileClose($search) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd The stripping of the path and extension is only there because it saves screen real-estate. It's easy to remove if you're okay with super-wide dropdowns. PROBLEM: For some reason this dropdown doesn't show a scroll bar for large numbers of files, at least on my computer. Probably something to do with the styles. just set the height to 100 or more on the combo box. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Sokko Posted November 18, 2005 Share Posted November 18, 2005 PROBLEM: For some reason this dropdown doesn't show a scroll bar for large numbers of files, at least on my computer. Probably something to do with the styles.Spoke too soon... it was the styles after all. $WS_VSCROLL is default on combo boxes, and I forgot to include it in the new style parameter. If you don't put that in, the dropdown doesn't scroll no matter how big you make it. Link to comment Share on other sites More sharing options...
ReFran Posted November 18, 2005 Share Posted November 18, 2005 (edited) " ... this is all for a program i'm writing for others and i dont want to offer them more than. file selection, not folder selection ... " Mmmh, I think the best way to get done the task is to set up a ListView GUI. You can quickly read in the files you want for selection from the folder you want. Sorting, selecting .... its not a problem with the helpful UDFs from Gary. Only Drag&Drag is not possible, but I think this you don't need/want. HTH, Reinhard PS: You may search for Holger's Explorer.exe to get an impression, how it works, also if that is far above that what you want. Edited November 18, 2005 by ReFran Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2005 Share Posted November 18, 2005 Instead of Listview, you may want to use a ListBox. Using the beta you could use _GUICtrlListAddDir Gary SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ReFran Posted November 18, 2005 Share Posted November 18, 2005 Instead of Listview, you may want to use a ListBox.Using the beta you could use _GUICtrlListAddDirGary" .... all i'm looking for is a way to view a "specific" folder, see the files, sort by name/date, and optionaly select some or all ..."That's possible with "_GUICtrlListAddDir" ??? With a listbox (GUICtrlCreateList) he view only one col. For a invisible Sort by date he would need a button and an extra array, if I interprete the help-files right. So a 2 cols listview, with using your UDFs (with included array UDFs), seems to me furtheron more simple.Best regards, Reinhard Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2005 Share Posted November 18, 2005 sorry, overlooked wanting to sort by name/date SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ReFran Posted November 18, 2005 Share Posted November 18, 2005 (edited) sorry, overlooked wanting to sort by name/dateYeah, that happens from time to time, especially at breakfast time. Have a nice working day, I'm going to start into the weekend, Reinhard Edited November 18, 2005 by ReFran Link to comment Share on other sites More sharing options...
GaryFrost Posted November 18, 2005 Share Posted November 18, 2005 (edited) expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> opt('MustDeclareVars', 1) Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index GUICreate("ListView Sort", 392, 322) $listview = GUICtrlCreateListView("File|Size|Type|Date Created|Date Modified", 40, 30, 310, 149, -1, BitOR($LVS_EX_REGIONAL, $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) _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() _PopulateListView($listview) Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ] 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)) 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 Edited November 18, 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. Link to comment Share on other sites More sharing options...
ReFran Posted November 18, 2005 Share Posted November 18, 2005 That's what I'm like in discussions with Gary .... mostly quick wonderful script examples. (.... mostly without stressing the people with long explanations.) The script works very well, thanks Gary. Best regards, Reinhard @Rick: Above Script would have been at least a half weekend for me. So excuse, that it isn't from me. Link to comment Share on other sites More sharing options...
Rick Posted November 19, 2005 Author Share Posted November 19, 2005 Nice that, thanks guys, altho now i need a way to select one or more files, ctrl A or ctrl shift/ ctrl click. or a selection tickbox or something. Any ideas on how i can do that?? Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
GaryFrost Posted November 19, 2005 Share Posted November 19, 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() _PopulateListView($listview) Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ] 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 19, 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. Link to comment Share on other sites More sharing options...
Rick Posted November 19, 2005 Author Share Posted November 19, 2005 Thats brilliant thanks! Who needs puzzles when we have AutoIt!! Link to comment Share on other sites More sharing options...
GaryFrost Posted November 19, 2005 Share Posted November 19, 2005 Thats brilliant thanks! had a problem with it, it should be fixed now, just copy the code i posted above SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
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