luxactor Posted May 19, 2009 Share Posted May 19, 2009 I've found some sample scripts here in forum and use them for my project, to list files/folders in a directory and show them in a dialog (later copy and burn them). Here my code:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GuiListView.au3> #include <ListviewConstants.au3> #Include <File.au3> #Include <Array.au3> Const $1GB = 1024 * 1024 * 1024 Const $1MB = 1024 * 1024 Const $1KB = 1024 $MAINGUI = GUICreate("Clips",482,302) GUISetState() $listview = GUICtrlCreateListView("#|Name|Größe|Erstellt am",5,40,470,200, -1, $LVS_EX_CHECKBOXES ) ;~ _GUICtrlListView_SetColumnWidth($listview, 0, $LVSCW_AUTOSIZE_USEHEADER) $button = GUICtrlCreateButton("Button",5,260,100,25) $directory = "c:\Windows\" $FileList=_FileListToArray($directory,'*.exe', 1) ; Only files If @Error=1 Then MsgBox (0,"","keine dateien gefunden") EndIf For $n = 1 to UBound($FileList)-1 $FileName = $FileList[$n] $FileSize = FileGetSize( $directory & "\" & $FileName) ;Dateigröße umrechnen Select Case $FileSize > $1GB $sApproximateSpace = $FileSize / $1GB $sComparison = "GB" Case $FileSize > $1MB And $FileSize < $1GB $sApproximateSpace = $FileSize / $1MB $sComparison = "MB" Case $FileSize >= "0" And $FileSize < $1MB $sApproximateSpace = $FileSize / $1KB $sComparison = "KB" Case Else EndSelect If StringInStr($sApproximateSpace, ".") Then $sApproximateSpace = StringTrimRight($sApproximateSpace, StringLen($sApproximateSpace) - StringInStr($sApproximateSpace, ".") - 1) Else EndIf ;Dateiliste darstellen $FileTime = FileGetTime($directory & "\" & $FileName, 1) $FileTimeDetail = $FileTime[2] & "/" & $FileTime[1] & "/" & $FileTime[0] & " " & $FileTime[3] & ":" & $FileTime[4] & ":" & $FileTime[5] $item = GUICtrlCreateListViewItem( "|" & $FileName & "|" & $sApproximateSpace & " " & $sComparison & "|" & $FileTimeDetail, $listview) Next While 1 $m = GUIGetMsg() If $m = $GUI_EVENT_CLOSE Then Exit If $m = $button Then _Select() EndIf WEnd Func _Select() Local $item_count = _GUICtrlListView_GetItemCount($listview) Local $is_checked, $items_checked, $file_array[1], $dest For $i = 0 To $item_count - 1 $is_checked = _GUICtrlListView_GetItemChecked($listview, $i) If Not @ERROR Then $items_checked += $is_checked If ($is_checked) Then If ($items_checked = 1) Then _ArrayInsert($file_array, 0, _GUICtrlListView_GetItemTextString($listview, $i)) _ArrayDelete($file_array, 1) Else _ArrayAdd($file_array, _GUICtrlListView_GetItemTextString($listview, $i)) EndIf EndIf EndIf Next If ($items_checked <> 0) Then If Not @ERROR Then FOR $i = 0 TO $items_checked - 1 MsgBox(0, "", $file_array[$i]) Next SplashOff() EndIf Else MsgBox(0, "", "blub") EndIf Sleep(10) EndFuncNo my problem is, my Select() function and _GUICtrlListView_GetItemTextString inside it, shows me the whole text from the listview. For example: "|bfsvc.exe|69.5 KB|22/...", but I need only the filename. Can someone help plz? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 19, 2009 Moderators Share Posted May 19, 2009 luxactor,In your Select() function, replace:_GUICtrlListView_GetItemTextString($listview, $i)with_GUICtrlListView_GetItemText($listview, $i, 1)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
luxactor Posted May 19, 2009 Author Share Posted May 19, 2009 (edited) Thanks a lot, works perfectly! Edited May 19, 2009 by luxactor 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