Jump to content

Working With ListBox and INI


Adamrv1
 Share

Recommended Posts

My Problems are getting information from my INI file(@scriptDir & "\PasswordsGUI.ini") to appear in the ListBox

Also, The Currently highlighted item on the list to be saved as the variable $WebsiteVar when $SelectBw is pressed

;Website Form
Func _WebsiteForm()
;website GUI
#Region ### START Koda GUI section ### Form=
$WebsiteF = GUICreate("Website", 202, 268, 292, 193)
$List1 = GUICtrlCreateList("", 16, 0, 169, 201)
GUICtrlSetData(-1, "Website1|Website2")
$SelectBw = GUICtrlCreateButton("Select", 16, 224, 169, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While $websitef
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($WebsiteF)
            ExitLoop

    EndSwitch
WEnd
EndFunc

Note: In order to help me with this script, you will need knowledge of IniWrite and IniRead

Note 2: Each seperate section of the INI is what i want to be saved

Example INI:

[Website1] ;<--this is to be listed
Username1: Password
Username2: Password

[Website2] ;<--as is this
Username1: Password
Username2: Password
Link to comment
Share on other sites

Read the data from the INI file using INI_* functions such as IniRead.

Insert that data into the listbox using the _GUICtrlListBox_* functions such as _GUICtrlListBox_AddString..

Here's an example:

$data = IniRead(@scriptDir & "\PasswordsGUI.ini", "Website1", "Username1", "DEFAULT")
_GUICtrlListBox_AddString($List1, $data)
My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Hi,

#include <GuiConstantsEx.au3>

Global $Ini = @ScriptDir & "\Websites.ini", $WebsiteVar

$WebsiteVar = _WebsiteForm()
If @error Then
    MsgBox(64, "Website Not Selected", "You didn't select a website from the list.", 4)
Else
    MsgBox(64, "Website Selected", $WebsiteVar, 4)
EndIf

Func _WebsiteForm()
    Local $WebsiteF, $List1, $SelectBw, $nMsg, $sGCR = ''

    $WebsiteF = GUICreate("Website", 202, 268, 292, 193)
    $List1 = GUICtrlCreateList("", 16, 0, 169, 201)
    $SelectBw = GUICtrlCreateButton("Select", 16, 224, 169, 33, 0)
    GUISetState(@SW_SHOW, $WebsiteF)

    _LoadList($Ini, $List1)

    While $WebsiteF
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Return SetError(GUIDelete($WebsiteF), 0, 0)
            Case $SelectBw
                $sGCR = GUICtrlRead($List1)
                If $sGCR <> '' Then Return SetError(GUIDelete($WebsiteF) = 0, 0, $sGCR)
        EndSwitch
    WEnd
EndFunc   ;==>_WebsiteForm

Func _LoadList($sIniFile, $iListID)
    Local $aIRSN, $i
    $aIRSN = IniReadSectionNames($sIniFile)
    If Not @error Then
        For $i = 1 To $aIRSN[0]
            GUICtrlSetData($iListID, $aIRSN[$i])
        Next
    EndIf
EndFunc   ;==>_LoadList

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