aness07 Posted September 2, 2012 Share Posted September 2, 2012 (edited) Hi.. I have create a script to get files form folder I have make a button to remove a file from listview how can i do it pleas help me this is the script .. expandcollapse popup#include #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("show file from folder", 453, 340, 192, 124) $ListView1 = GUICtrlCreateListView("File name|Attribute|Track", 8, 8, 442, 294) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 125) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) $BDeleteFile = GUICtrlCreateButton("Delete file", 328, 304, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ ----------------------------------------------- $DIR = "E:aness" ;~ get the file inot array $FILE = _FileListToArray($DIR,"*") Func ShowFils() sleep(500) For $INDEX = 1 To $FILE[0] $POINT = StringInStr($FILE[$INDEX],".",0,-1) ;~ if there are an error or searching file end ExitLoop If @error Then ExitLoop ;~ get the attrib of file $att = FileGetAttrib($DIR& ""&$FILE[$INDEX]) ;~ checking about the attrib of file $check_att = StringInStr($att,"H") ;~ if stringinstr Returned True if $check_att <> 0 Then If $POINT <> 0 Then ;~ adding the hidden to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf Else If $POINT <> 0 Then ;~ adding the view to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Not Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf EndIf Next EndFunc ;~ ---------------------------------------------------- ShowFils() ;~ ------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BDeleteFile ;~ what It should to do EndSwitch WEnd this is my example.. thank you Edited September 2, 2012 by aness07 Link to comment Share on other sites More sharing options...
Danyfirex Posted September 2, 2012 Share Posted September 2, 2012 (edited) maybe so. expandcollapse popup#include <array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("show file from folder", 453, 340, 192, 124) $ListView1 = GUICtrlCreateListView("File name|Attribute|Track", 8, 8, 442, 294) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 125) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) $BDeleteFile = GUICtrlCreateButton("Delete file", 328, 304, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ ----------------------------------------------- $DIR = "C:Program Files" ;~ get the file inot array $FILE = _FileListToArray($DIR,"*") Func ShowFils() sleep(500) For $INDEX = 1 To $FILE[0] $POINT = StringInStr($FILE[$INDEX],".",0,-1) ;~ if there are an error or searching file end ExitLoop If @error Then ExitLoop ;~ get the attrib of file $att = FileGetAttrib($DIR& ""&$FILE[$INDEX]) ;~ checking about the attrib of file $check_att = StringInStr($att,"H") ;~ if stringinstr Returned True if $check_att <> 0 Then If $POINT <> 0 Then ;~ adding the hidden to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf Else If $POINT <> 0 Then ;~ adding the view to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Not Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf EndIf Next EndFunc ;~ ---------------------------------------------------- ShowFils() ;~ ------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BDeleteFile $path=_GUICtrlListView_GetItemText($ListView1, 0,2) msgbox(0,"",$path) ; show the path to del on msgbox ;FileDelete($path) use to delete EndSwitch WEnd Edited September 2, 2012 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
aness07 Posted September 2, 2012 Author Share Posted September 2, 2012 Thank you DanyfirexBut this will help me to remove only the first file ... I want to remove a file the user choose itThank you again Link to comment Share on other sites More sharing options...
Danyfirex Posted September 2, 2012 Share Posted September 2, 2012 mmm Try this. expandcollapse popup#include <array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("show file from folder", 453, 340, 192, 124) $ListView1 = GUICtrlCreateListView("File name|Attribute|Track", 8, 8, 442, 294) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 125) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) $BDeleteFile = GUICtrlCreateButton("Delete file", 328, 304, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ ----------------------------------------------- $DIR = "C:" ;~ get the file inot array $FILE = _FileListToArray($DIR,"*") Func ShowFils() sleep(500) For $INDEX = 1 To $FILE[0] $POINT = StringInStr($FILE[$INDEX],".",0,-1) ;~ if there are an error or searching file end ExitLoop If @error Then ExitLoop ;~ get the attrib of file $att = FileGetAttrib($DIR& ""&$FILE[$INDEX]) ;~ checking about the attrib of file $check_att = StringInStr($att,"H") ;~ if stringinstr Returned True if $check_att <> 0 Then If $POINT <> 0 Then ;~ adding the hidden to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf Else If $POINT <> 0 Then ;~ adding the view to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Not Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf EndIf Next EndFunc ;~ ---------------------------------------------------- ShowFils() ;~ ------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BDeleteFile $path= _GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),2) msgbox(0,"",$path) ; show the path to del on msgbox ;FileDelete($path) use to delete EndSwitch WEnd Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
aness07 Posted September 2, 2012 Author Share Posted September 2, 2012 Thank you Danyfirex very much ... It works well Link to comment Share on other sites More sharing options...
Danyfirex Posted September 2, 2012 Share Posted September 2, 2012 Thank you Danyfirex very much ... It works well You're welcome. regards Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
enigmaforceiv Posted September 2, 2012 Share Posted September 2, 2012 Can one of you explain how this works on the user's side? Do they click to choose the file that they want to delete? I'm looking to do something similar, but would like the event to open the directory and its contents within. Link to comment Share on other sites More sharing options...
Danyfirex Posted September 2, 2012 Share Posted September 2, 2012 Can one of you explain how this works on the user's side? Do they click to choose the file that they want to delete? I'm looking to do something similar, but would like the event to open the directory and its contents within. maybe you should create a new topic. try this. expandcollapse popup#include <array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3>#Region ### START Koda GUI section ### Form= $Form1 = GUICreate("show file from folder", 453, 340, 192, 124) $ListView1 = GUICtrlCreateListView("File name|Attribute|Track", 8, 8, 442, 294) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 125) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) $BDeleteFile = GUICtrlCreateButton("Delete file", 328, 304, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ ----------------------------------------------- $DIR = "C:windows" ;~ get the file inot array $FILE = _FileListToArray($DIR,"*") Func ShowFils() sleep(500) For $INDEX = 1 To $FILE[0] $POINT = StringInStr($FILE[$INDEX],".",0,-1) ;~ if there are an error or searching file end ExitLoop If @error Then ExitLoop ;~ get the attrib of file $att = FileGetAttrib($DIR& ""&$FILE[$INDEX]) ;~ checking about the attrib of file $check_att = StringInStr($att,"H") ;~ if stringinstr Returned True if $check_att <> 0 Then If $POINT <> 0 Then ;~ adding the hidden to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf Else If $POINT <> 0 Then ;~ adding the view to liswiew GUICtrlCreateListViewItem($FILE[$INDEX] & "|" & "Not Hidden"&"|"&$DIR&""&$FILE[$INDEX],$ListView1) EndIf EndIf Next EndFunc ;~ ---------------------------------------------------- ShowFils() ;~ ------------------------------------------------------- While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $BDeleteFile local $path= _GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),2) ShellExecute($path) $path=dir($path) Run("Explorer " & $path) ;msgbox(0,"",$path) ; show the path to del on msgbox ;FileDelete($path) use to delete EndSwitch WEnd func dir($path) local $delimiter="" $array =StringSplit($path,$delimiter) $len=UBound($array)-1 $numero= $len-1 $num=StringInStr($path,$delimiter,0,$numero) $dir=StringMid($path,1,$num) return $dir EndFunc Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut 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