Jump to content
Sign in to follow this  

Help Me About Listview

Recommended Posts

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



Share this post

Link to post
Share on other sites

No, I read the help files but i didnt find a way to save all the items of a listview

for example i have:




i want to save all of these items to a text file

Share this post

Link to post
Share on other sites

What shall I give you?


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.

Share this post

Link to post
Share on other sites

#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)
While 1
    $msg = GuiGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
    Case $msg = $add
        $dia = FileOpenDialog("Add a song","::{450D8FBA-AD25-11D0-98A8-0800361B1103}","MP3's and WAVs (*.mp3;*.wav)")
        If @error  Then 
        $FullPath = StringSplit($dia,"\")
        $PathFile = $FullPath[UBound($FullPath)-1]
        GuiCtrlCreateListViewItem($PathFile & "|" & $dia,$list)
    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)
    Case $msg = $remove
        if GUICtrlRead(GUICtrlRead($list)) = "" then ContinueLoop
    Case $msg = $openplay
        $dia = FileOpenDialog("Open a playlist",@ScriptDir,"Playlist file (*.pli)")
        if @error Then
        $file = FileOpen($dia,0)
        $line = ""
        While 1
            $line = FileReadLine($file)
        If @error = -1 Then ExitLoop
    Case $msg = $save
        $dia = FileSaveDialog("Save playlist",@ScriptDir,"Playlist file (*.pli)")
        if @error then ContinueLoop
            if StringRight($dia,4) = ".pli" Then
                $dia = $dia & ".pli"
#endregion --- GuiBuilder generated code End ---

After the last case ($msg = $save) The program will see whether the path ends with .pli or not

if 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.

Share this post

Link to post
Share on other sites


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)

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...