Sign in to follow this  
Followers 0
DVHRLD

IniSection to ListBox

4 posts in this topic

How can I take an ini section and put it into a ListBox

Here is what I have so far with the script not being able to run.

Thanks for your help... again.

MyScript.au3

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <file.au3>
#Include <GuiListBox.au3>




$proxylist = StringSplit(IniReadSection("MyIni.ini", "Proxy")"|")
For $I = 1 To $proxylist[0]
     GUICtrlCreateListViewItem($proxylist[$I], $proxlist)
  Next
      _GUICtrlListBox_UpdateHScroll($proxlist)
    _GUICtrlListBox_EndUpdate($proxlist)
    
    
    
    $gui = GUICreate("My Gui", 430, 120)
      $proxies = GUICtrlCreateTabItem("Proxies")
      $proxlist = GUICtrlCreateList($proxylist, 10, 20, 200, 80)
          GUISetState(@SW_SHOW)
        
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete()

MyIni.ini

[Url]
url1=http://google.com
url2=http://msn.com
url3=http://google.ca
url4=http://yahoo.com

[Proxy]
128.112.139.71:3128
128.112.139.75:3128
128.112.139.78:3128

AutoViewer first public AutoIt script

Share this post


Link to post
Share on other sites



Take a look at IniReadSection, it returns an Array(). You can't use "String" functions on an array.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi,

#include <GUIConstantsEx.au3>

Global $Ini = @ScriptDir & "\MyIni.ini"

$gui = GUICreate("My Gui", 430, 120)
$Tab0 = GUICtrlCreateTab(5, 5, 420, 110)
$Urls = GUICtrlCreateTabItem("Url")
$urllist = GUICtrlCreateList("", 10, 35, 200, 80)
_FillList($urllist, $Ini, "Url")
$proxies = GUICtrlCreateTabItem("Proxies")
$proxlist = GUICtrlCreateList("", 10, 35, 200, 80)
_FillList($proxlist, $Ini, "Proxy")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW, $gui)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            ;;;
    EndSwitch
WEnd

Func _FillList($cID, $IniPath, $sSection)
    Local $aSection = IniReadSection($IniPath, $sSection)
    If Not @error Then
        For $i = 1 To $aSection[0][0]
            GUICtrlSetData($cID, $aSection[$i][1])
        Next
    EndIf   
EndFunc

For your ini you need to add keys for the [Proxies] section for the example to work..

[Url]
url1=http://google.com
url2=http://msn.com
url3=http://google.ca
url4=http://yahoo.com

[Proxy]
1=128.112.139.71:3128
2=128.112.139.75:3128
3=128.112.139.78:3128

Cheers

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

OK thanks smashly

Edited by DVHRLD

AutoViewer first public AutoIt script

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  
Followers 0