AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting All Data Out Of A Listview

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Fry



Joined: 01 Nov 2007
Posts: 609

PostPosted: Sun May 04, 2008 5:23 pm    Post subject: Getting All Data Out Of A Listview Reply with quote

I am trying to get all data out of a listview.

Heres what my listview would look like

Code:
Name|Extension|Directory
__________________________________
AHK.ahk|ahk|C:\Blah
txt.txt|txt|D:\blah
___________________________________


I would like to extract all of that information and append it to a text file.

But in this format

Name|Extension|Directory

or another example

Ahk.ahk|ahk|C:\Blah


Thanks
_________________
check out my site
www.eliteknifesquad.com
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 458

PostPosted: Sun May 04, 2008 5:45 pm    Post subject: Reply with quote

See the example for LV_GetNext()
Back to top
View user's profile Send private message
skwire



Joined: 18 Jan 2006
Posts: 132
Location: Conway, Arkansas

PostPosted: Sun May 04, 2008 6:18 pm    Post subject: Reply with quote

Consider the following example:

Code:
Gui, Add, Listview, xm    ym+10  w200 h100 Grid vmyListview    , Name|Extension|Directory
Gui, Add, Button  , xm+10 ym+115 w180 h20                   gDo, Get list data

; Populate list with some data bits.
LV_Add( 1, "AHK.ahk", "ahk", "C:\Blah" )
LV_Add( 2, "txt.txt", "txt", "D:\Blah" )

Gui +LastFound
GUI_ID := WinExist() ; Handle to the GUI

Gui, Show, AutoSize
Return

Do:
{
    Gui, Listview, myListview    ; Assure we work on the correct listview.
    Loop, % LV_GetCount( "Col" ) ; Loop for however many columns are in the listview.
    {
        LV_GetText( myHeader, 0, A_INDEX ) ; Get column header.
        Header_Line .= myHeader . "|"      ; Build output data.
    }
    StringTrimRight, Header_Line, Header_Line, 1 ; Trim trailing pipe char.

    ControlGet, List, List, , SysListView321, ahk_id %GUI_ID% ;
    StringReplace, List, List, %A_Tab%, |, All

    MsgBox, % Header_Line . "`n" . List
}
Return

GuiEscape:
GuiClose:
{
    ExitApp
}
Return
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Fry



Joined: 01 Nov 2007
Posts: 609

PostPosted: Sun May 04, 2008 8:32 pm    Post subject: Reply with quote

Thanks skwire but if you click the button once it works fine.

then click it again you get this


Name|Extension|DirectoryName|Extension|Directory
_________________
check out my site
www.eliteknifesquad.com
Back to top
View user's profile Send private message
Ian



Joined: 15 Jul 2007
Posts: 1157
Location: Enterprise, Alabama

PostPosted: Sun May 04, 2008 8:47 pm    Post subject: Reply with quote

Code:
Gui, Add, Listview, xm    ym+10  w200 h100 Grid vmyListview    , Name|Extension|Directory
Gui, Add, Button  , xm+10 ym+115 w180 h20                   gDo, Get list data

; Populate list with some data bits.
LV_Add( 1, "AHK.ahk", "ahk", "C:\Blah" )
LV_Add( 2, "txt.txt", "txt", "D:\Blah" )

Gui +LastFound
GUI_ID := WinExist() ; Handle to the GUI

Gui, Show, AutoSize
Return

Do:
Header_Line = ;  Make sure Header_Line variable is clear
List        = ; Make sure List variable is clear.
Gui, Listview, myListview    ; Assure we work on the correct listview.
Loop, % LV_GetCount( "Col" ) ; Loop for however many columns are in the listview.
{
    LV_GetText( myHeader, 0, A_INDEX ) ; Get column header.
    Header_Line .= myHeader . "|"      ; Build output data.
}
StringTrimRight, Header_Line, Header_Line, 1 ; Trim trailing pipe char.

ControlGet, List, List, , SysListView321, ahk_id %GUI_ID% ;
StringReplace, List, List, %A_Tab%, |, All

MsgBox, % Header_Line . "`n" . List
Return

GuiEscape:
GuiClose:
ExitApp
Return

_________________
ScriptPad/~dieom/dieom/izwian2k7/Trikster/God

Back to top
View user's profile Send private message
Fry



Joined: 01 Nov 2007
Posts: 609

PostPosted: Sun May 04, 2008 8:56 pm    Post subject: Reply with quote

Thanks Ian.
_________________
check out my site
www.eliteknifesquad.com
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group