ryoken Posted July 4, 2009 Share Posted July 4, 2009 Alright, What I'm trying to do here is make it so when my program starts up, it loads items from an ini file to a list. What i'm exactly trying to do is make it so you save account information in an ini file. Then the names of the saved accounts appear on the list when the program starts up. When you click on the list item, it puts the username and password of that account into the corresponding boxes. Can anyone help me with this? Link to comment Share on other sites More sharing options...
BrettF Posted July 4, 2009 Share Posted July 4, 2009 Whats the INI look like? What have you tried? Do you have any code to show us? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ryoken Posted July 4, 2009 Author Share Posted July 4, 2009 (edited) Ini File: [Accounts] Name = test Username1 = test Password1 = test I've tried setting the data of the list using GUICtrlSetData but that doesen't seem to work properly. There's really no code to show because all i really have right now is a normal gui with a menu control. Edited July 4, 2009 by ryoken Link to comment Share on other sites More sharing options...
Authenticity Posted July 4, 2009 Share Posted July 4, 2009 #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> Opt('GUIOnEventMode', 1) Global $hGUI = GUICreate('Test', 250, 350) Global $ListView = GUICtrlCreateListView('Account |Password ', 20, 20, 210, 310, BitOR($LVS_DEFAULT, $LVS_NOSORTHEADER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) _GetAccounts() GUISetOnEvent($GUI_EVENT_CLOSE, '_Close') GUISetState() While 1 Sleep(20) WEnd Func _GetAccounts() Local $aAccounts = IniReadSection(@ScriptDir & '\file.ini', 'Accounts') If Not @error Then For $i = 1 To $aAccounts[0][0] GUICtrlCreateListViewItem($aAccounts[$i][0] & '|' & $aAccounts[$i][1], $ListView) GUICtrlSetOnEvent(-1, '_ListViewHandler') Next EndIf EndFunc Func _Close() GUIDelete() Exit EndFunc Func _ListViewHandler() Local $aPair = StringSplit(StringTrimRight(GUICtrlRead(@GUI_CtrlId), 1), '|', 2) If UBound($aPair) = 2 Then MsgBox(0x40, 'Account/Pass', 'Account: ' & $aPair[0] & @CRLF & 'Pass: ' & $aPair[1]) EndFuncI thought more in this direction, it's quite easy to implement and modify the script to your preferred way:file.ini:[Accounts] ABC=DEF 123=456 leopard=panther et=cetra Link to comment Share on other sites More sharing options...
BrettF Posted July 4, 2009 Share Posted July 4, 2009 You obviously didn't run is code or read the provided INI because it should be staring you in the face. In the INI... USERNAME=PASSWORD Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ryoken Posted July 4, 2009 Author Share Posted July 4, 2009 whoops forgot to rename the file I'm still having trouble understanding the script itself and how it works but i guess I'll figure that out over time. Thank you both. Link to comment Share on other sites More sharing options...
BrettF Posted July 4, 2009 Share Posted July 4, 2009 I hope you've managed to realise that the function _GetAccounts() loads data into the listview. Local $aAccounts = IniReadSection(@ScriptDir & '\file.ini', 'Accounts') This reads the entries in the INI file under the section "Accounts" ([Accounts] in the INI file), and outputs a 2D array in the form where element[n][0] is the key and element[n][1] is the value. We then check for errors (first If statement) and GUICtrlCreateListViewItem($aAccounts[$i][0] & '|' & $aAccounts[$i][1], $ListView) This sets the data in the listview as per what it returns. GUICtrlSetOnEvent(-1, '_ListViewHandler') This sets an even when you click on a listview item. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now