Jump to content

ini to list


 Share

Recommended Posts

Hey,

I need some help getting the contents of an ini file to a list. The contents in the ini file is layed out like this.

[*name of file*]
url=*url to get file*
id=*file number*
size=*rough file size*

repeated many times...

The list will need to display the filename, size and version(id/filenumber).

GuiCtrlCreateListView ("Filename|Size[MB]|Version"...

There will need to be a download button that sees which file the user clicked on in the list and run a function (which i have already coded) which needs the file name and url variables sent to it.

I have never used lists before, so i have no clue what i'm doing but if someone could do that part of the script for me it would be very appreciated.

Link to comment
Share on other sites

Presuming this is your ini:

[file1]
size=sizeoffile1
version=versionofFile1
url=urlFile1
id=file1ID

[file3]
url=urlFile3
version=versionofFile3
id=file3ID
size=sizeoffile3

[file2]
url=urlFile2
id=file2ID
size=sizeoffile2
version=versionofFile2

then:

#include <GUIConstants.au3>

GUICreate("listview items",400,400, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF)  ; will change background color

$listview = GUICtrlCreateListView ("File|Size|Version",10,10,300,150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton ("Value?",75,170,70,20)

$input1=GUICtrlCreateInput("",20,200, 150)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)   ; to allow drag and dropping
GUISetState()


$namesArray = IniReadSectionNames('test.ini')
if not @error Then
    dim $item[UBound($namesArray)+1]
    For $i = 1 to UBound($namesArray)-1
        $keyArray = IniReadSection('test.ini',$namesArray[$i])
        If Not @error Then
            $size=''
            $version=''
            For $k = 1 to UBound($keyArray,1)-1
                If StringLower($keyArray[$k][0])='size' Then $size = $keyArray[$k][1]
                If StringLower($keyArray[$k][0])='version' Then $version = $keyArray[$k][1]
            Next
        EndIf
        $item[$i] = GUICtrlCreateListViewItem($namesArray[$i] & '|' & $size & "|" & $version,$listview)
    Next
EndIf

Do
  $msg = GUIGetMsg ()
     
   Select
      Case $msg = $button
         MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
      Case $msg = $listview
         MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
   EndSelect
Until $msg = $GUI_EVENT_CLOSE

Cheers.

Link to comment
Share on other sites

thanks, dat helped alot :P when the user clicks the button how do i get just the filename so it can read in the url from the ini file.

EDIT: dw i worked it out, probably the messy coding way :D

$clicked=GUICtrlRead(GUICtrlRead($listview))
$array = StringSplit($clicked, '|', 1)
MsgBox(0,"listview item",$array[1])
Edited by davgkill
Link to comment
Share on other sites

thanks, dat helped alot :D just one more thing! when the user clicks the button how do i get just the filename so it can read in the url from the ini file.

you can use stringsplit to split the string and pull out the file name, or you can just read the url in with all the other info.--meaining since your reading the ini into the list, then split and read the url itself.

Edited by stampy
Link to comment
Share on other sites

$listview = GUICtrlCreateListView ("File|Size MB|Version",10,35,380,150)

GUICtrlSendMsg(-1, 0x101E, 0, 200)

GUICtrlSendMsg(-1, 0x101E, 1, 200)

GUICtrlSendMsg(-1, 0x101E, 2, 200)

hope it helps

You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...