Jump to content

IniSection to ListBox


DVHRLD
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

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.

Link to comment
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

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