Guest AX5 Posted January 12, 2010 Share Posted January 12, 2010 Can understand how do select a file from list the you can press Delete to remove the file from list expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #Include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Demo Manager", 427, 296, 231, 155) $Button1 = GUICtrlCreateButton("Choose a folder", 272, 110, 113, 33, $WS_GROUP) $Button3 = GUICtrlCreateButton("Move", 272, 168, 113, 33, $WS_GROUP) $Button4 = GUICtrlCreateButton("Remove", 272, 208, 113, 33, $WS_GROUP) $Label1 = GUICtrlCreateLabel(" File Display", 115, 52, 60, 15) $List1 = GUICtrlCreateList("Files will Display here", 32, 72, 225, 201) $Pic1 = GUICtrlCreatePic("img/", 0, 0, 427, 296, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 List_Folder_Contents() Case $Button3 Case $Button4 GUICtrlListView_DeleteItemsSelected() EndSwitch WEnd Func List_Folder_Contents() ; Choose folder $sFolderPath = FileSelectFolder("Choose a folder", "M:\") If $sFolderPath = "" Then Return ; No folder chosen ; Clear list GUICtrlSetData($List1, "|") ; List contents into array $aFile_Array = _FileListToArray($sFolderPath, "*", 1) ; If no files found If @error Then GUICtrlSetData($List1, "|No files found!") Return EndIf ; Move found files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFunc Func GUICtrlListView_DeleteItemsSelected() $List1 = $List1 _GUICtrlListView_SetItemSelected($List1, Random(0, UBound($aItems) - 1, 1)) EndFunc Link to comment Share on other sites More sharing options...
water Posted January 12, 2010 Share Posted January 12, 2010 Use _GUICtrlListView_GetSelectedIndices to get a list of selected indices. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Guest AX5 Posted January 12, 2010 Share Posted January 12, 2010 Dont understand a shit hahaha from the HELP file hehehe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 12, 2010 Moderators Share Posted January 12, 2010 AX5,You cannot use the _GUICtrlListView functions on List controls - as the name suggests they only work on ListView controls. This should do what you want:expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #Include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> Global $aFile_Array[1] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Demo Manager", 427, 296, 231, 155) $Button1 = GUICtrlCreateButton("Choose a folder", 272, 110, 113, 33, $WS_GROUP) $Button3 = GUICtrlCreateButton("Move", 272, 168, 113, 33, $WS_GROUP) $Button4 = GUICtrlCreateButton("Remove", 272, 208, 113, 33, $WS_GROUP) $Label1 = GUICtrlCreateLabel(" File Display", 115, 52, 60, 15) $List1 = GUICtrlCreateList("Files will Display here", 32, 72, 225, 201) $Pic1 = GUICtrlCreatePic("img/", 0, 0, 427, 296, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 List_Folder_Contents() Case $Button3 Case $Button4 DeleteFromList() EndSwitch WEnd Func List_Folder_Contents() ; Choose folder $sFolderPath = FileSelectFolder("Choose a folder", "M:\") If $sFolderPath = "" Then Return ; No folder chosen ; Clear list GUICtrlSetData($List1, "|") ; List contents into array $aFile_Array = _FileListToArray($sFolderPath, "*", 1) ; If no files found If @error Then GUICtrlSetData($List1, "|No files found!") Return EndIf ; Move found files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFunc Func DeleteFromList() ; Find index of selected file $iIndex = _ArraySearch($aFile_Array, GUICtrlRead($List1)) If Not @Error Then ; Delete from array and adjust count _ArrayDelete($aFile_Array, $iIndex) $aFile_Array[0] -= 1 EndIf ; Empty list GUICtrlSetData($List1, "") ; Put remaining files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFuncM23 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...
Guest AX5 Posted January 12, 2010 Share Posted January 12, 2010 AX5, You cannot use the _GUICtrlListView functions on List controls - as the name suggests they only work on ListView controls. This should do what you want: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #Include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> Global $aFile_Array[1] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Demo Manager", 427, 296, 231, 155) $Button1 = GUICtrlCreateButton("Choose a folder", 272, 110, 113, 33, $WS_GROUP) $Button3 = GUICtrlCreateButton("Move", 272, 168, 113, 33, $WS_GROUP) $Button4 = GUICtrlCreateButton("Remove", 272, 208, 113, 33, $WS_GROUP) $Label1 = GUICtrlCreateLabel(" File Display", 115, 52, 60, 15) $List1 = GUICtrlCreateList("Files will Display here", 32, 72, 225, 201) $Pic1 = GUICtrlCreatePic("img/", 0, 0, 427, 296, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 List_Folder_Contents() Case $Button3 Case $Button4 DeleteFromList() EndSwitch WEnd Func List_Folder_Contents() ; Choose folder $sFolderPath = FileSelectFolder("Choose a folder", "M:\") If $sFolderPath = "" Then Return ; No folder chosen ; Clear list GUICtrlSetData($List1, "|") ; List contents into array $aFile_Array = _FileListToArray($sFolderPath, "*", 1) ; If no files found If @error Then GUICtrlSetData($List1, "|No files found!") Return EndIf ; Move found files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFunc Func DeleteFromList() ; Find index of selected file $iIndex = _ArraySearch($aFile_Array, GUICtrlRead($List1)) If Not @Error Then ; Delete from array and adjust count _ArrayDelete($aFile_Array, $iIndex) $aFile_Array[0] -= 1 EndIf ; Empty list GUICtrlSetData($List1, "") ; Put remaining files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFunc M23 Thx man but the file dos not remove in the Folder only on the list Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 12, 2010 Moderators Share Posted January 12, 2010 AX5, but the file dos not remove in the Folder only on the listBut that is what you asked for! you can press Delete to remove the file from listSeriously, to delete the file, use FileDelete . You already have $sFolderPath and by adjusting the first few lines of the DeleteFromList() function like this: ; Get name of selected file $sFileName = GUICtrlRead($List1) ; Find index of selected file $iIndex = _ArraySearch($aFile_Array, $sFileName) you have the name as well. What more do you need? Could I suggest using FileRecycle (at least at first) to keep the safety net of the Recycle Bin. You would not want to permanently delete something important, would you! Over to you! 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...
Guest AX5 Posted January 12, 2010 Share Posted January 12, 2010 (edited) Omg im confused Is this right ? expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #Include <GuiListView.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> Global $aFile_Array[1] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Demo Manager", 427, 296, 231, 155) $Button1 = GUICtrlCreateButton("Choose a folder", 272, 110, 113, 33, $WS_GROUP) $Button3 = GUICtrlCreateButton("Move", 272, 168, 113, 33, $WS_GROUP) $Button4 = GUICtrlCreateButton("Remove", 272, 208, 113, 33, $WS_GROUP) $Label1 = GUICtrlCreateLabel(" File Display", 115, 52, 60, 15) $List1 = GUICtrlCreateList("Files will Display here", 32, 72, 225, 201) $Pic1 = GUICtrlCreatePic("img/", 0, 0, 427, 296, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 List_Folder_Contents() Case $Button3 Case $Button4 DeleteFromList() EndSwitch WEnd Func List_Folder_Contents() ; Choose folder $sFolderPath = FileSelectFolder("Choose a folder", "M:\") If $sFolderPath = "" Then Return ; No folder chosen ; Clear list GUICtrlSetData($List1, "|") ; List contents into array $aFile_Array = _FileListToArray($sFolderPath, "*", 1) ; If no files found If @error Then GUICtrlSetData($List1, "|No files found!") Return EndIf ; Move found files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFunc Func DeleteFromList() $sFileName = GUICtrlRead($List1) ; Find index of selected file $iIndex = _ArraySearch($aFile_Array, $sFileName) If Not @Error Then ; Delete from array and adjust count _ArrayDelete($aFile_Array, $iIndex) $aFile_Array[0] -= 1 EndIf ; Empty list GUICtrlSetData($List1, "") ; Put remaining files into list For $i = 1 To $aFile_Array[0] GUICtrlSetData($List1, $aFile_Array[$i]) Next EndFunc Edited January 12, 2010 by AX5 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 12, 2010 Moderators Share Posted January 12, 2010 AX5,Well, you now have $FolderPath and $sFileName - so you can identify the file to be deleted. Have you looked at FileDelete or FileRecycle in the Help file to see how to use them? How do you think the 2 variables might fit into the commands?Come on, start doing some of this yourself! 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...
Guest AX5 Posted January 12, 2010 Share Posted January 12, 2010 I fixed it Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 12, 2010 Moderators Share Posted January 12, 2010 AX5, Good for you! 23 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...
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