PC.MAX Posted April 13, 2006 Share Posted April 13, 2006 Hello everyone, How can I read items from a listview and save them as a text file? Link to comment Share on other sites More sharing options...
Valuater Posted April 13, 2006 Share Posted April 13, 2006 welcome to the forums... you have obviously read some of the help file to get this far... so if you could post some script ... just what you have so far then we can help 8) Link to comment Share on other sites More sharing options...
PC.MAX Posted April 13, 2006 Author Share Posted April 13, 2006 No, I read the help files but i didnt find a way to save all the items of a listviewfor example i have:Item1|Data1Item2|Data2etc....|etc....i want to save all of these items to a text file Link to comment Share on other sites More sharing options...
Valuater Posted April 13, 2006 Share Posted April 13, 2006 your not giving enough information...especially... not enough scriptto help you8) Link to comment Share on other sites More sharing options...
PC.MAX Posted April 13, 2006 Author Share Posted April 13, 2006 What shall I give you? Link to comment Share on other sites More sharing options...
Shao Posted April 13, 2006 Share Posted April 13, 2006 What shall I give you?Hi,To be able to give you some help, we need to know what is in your script, so please, give us an extract of your script, how is your listview like. Link to comment Share on other sites More sharing options...
PC.MAX Posted April 14, 2006 Author Share Posted April 14, 2006 expandcollapse popup#region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.6 Prototype #include <GuiConstants.au3> GuiCreate("MP3 Player", 800, 363,-1, -1) $list = GUICtrlCreateListView("Song name|Song destination", 30, 20,590, 266) $openplay = GuiCtrlCreateButton("Open a playlist", 650, 20, 140, 40) $add = GUICtrlCreateButton("Add a song to the playlist",650,120,140,40) $save = GuiCtrlCreateButton("Save playlist", 650, 70, 140, 40) $open = GuiCtrlCreateButton("Open the selected song", 30, 300, 290, 30) $remove = GuiCtrlCreateButton("Remove the selected song from the playlist", 340, 300, 280, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $add $dia = FileOpenDialog("Add a song","::{450D8FBA-AD25-11D0-98A8-0800361B1103}","MP3's and WAVs (*.mp3;*.wav)") If @error Then Else $FullPath = StringSplit($dia,"\") $PathFile = $FullPath[UBound($FullPath)-1] GuiCtrlCreateListViewItem($PathFile & "|" & $dia,$list) EndIf Case $msg = $open if GUICtrlRead(GUICtrlRead($list)) = "" then ContinueLoop $FullPath = StringSplit(GUICtrlRead(GUICtrlRead($list)),"|") $FullPath = $FullPath[UBound($FullPath)-1] $string = @COMSPEC & " /c start " & FileGetShortName($FullPath) Run($string) Case $msg = $remove if GUICtrlRead(GUICtrlRead($list)) = "" then ContinueLoop GUICtrlDelete(GUICtrlRead($list)) Case $msg = $openplay $dia = FileOpenDialog("Open a playlist",@ScriptDir,"Playlist file (*.pli)") if @error Then Else $file = FileOpen($dia,0) $line = "" While 1 $line = FileReadLine($file) GUICtrlCreateListViewItem($list,$line) If @error = -1 Then ExitLoop Wend FileClose($file) EndIf Case $msg = $save $dia = FileSaveDialog("Save playlist",@ScriptDir,"Playlist file (*.pli)") if @error then ContinueLoop if StringRight($dia,4) = ".pli" Then Else $dia = $dia & ".pli" EndIf EndSelect WEnd Exit #endregion --- GuiBuilder generated code End ---After the last case ($msg = $save) The program will see whether the path ends with .pli or notif it doesnt the program will add .pli to the path.after that I want it to save the items from the listview and save all of the items to that .pli file.I couldnt find a way to do that. Link to comment Share on other sites More sharing options...
Shao Posted April 16, 2006 Share Posted April 16, 2006 Hi, I think it's not a very good beginning in your script because when you create your listview, no array-variable is used to call back the listviewitem. Well, it looks to be easy enough about the theory : - insert all the items in an array using a loop (for...next, for example) #Include <GuiListView.au3> ... dim $array[$end+1] $i = 1 for $i = 1 to $end $array[$i]=_GUICtrlListViewInsertItem($h_listview, $i_index, $s_text) Like it, you can use for...next to save your items by saving the array : _FileWriteFromArray($FilePath, $array, 1) _FileWriteFromArray has a parameter set to 1 because 0=index (in this case= number of files of the playlist) 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