Andrew Sparkes Posted September 26, 2005 Posted September 26, 2005 Okay. The problem: I want to read from an ini and make controls based on the contents of the ini. Checkboxes or Radios, I've gone back and forth. And once the controls are there and one is selected and the start button is hit, I want a function to use the controls name in the ini and read email and password and pass that on to another login function (in DCL.au3). I need to name the Checkboxes or Radios uniquely, but it gives an error if I try to use $control[$i]=. Anyone has insight? Is my programming the problem? or is it not possible? Here is my current code: expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: Sparkes ; ; Script Function: ; DT Login ; ; ---------------------------------------------------------------------------- #include <GUIConstants.au3> #include <DCL.au3>; includes Login($un,$pw), Logout(), and close() $accounts="accounts.ini" $error="404 Error: File Not Found" $GUIMain = GUICreate("DT Login",350,400,300,100) Opt("GUIOnEventMode",1) GUISetOnEvent($GUI_EVENT_CLOSE, "close") HotKeySet("{Esc}","close") GUICtrlCreateLabel("Accounts:",10,10) $loginbutton = GUICtrlCreateButton("Login",300,350,50,50) GUICtrlSetOnEvent($loginbutton,"Start") GUISetState() Dim $control Dim $sectionnames = IniReadSectionNames($accounts) If Not FileExists($accounts) Then MsgBox(0,"Error","Error") Else $g=1 For $i = 1 To $sectionnames[0] ;$control[$i] = GUICtrlCreateCheckbox($sectionnames[$i],20,(10+$g*20),150,20) GUICtrlCreateCheckbox($sectionnames[$i],20,(10+$g*20),150,20) $g=$g+1 Next EndIf While 1 Sleep(10000) WEnd Func Start() EndFunc And a sample accounts.ini [1] email=a password=b [2] email=c password=d [3] email=e password=f [4] email=g password=h [5] email=i password=j ---Sparkes.
DoctorX Posted September 26, 2005 Posted September 26, 2005 Here is a function I wrote that does something similar to what you are trying to do. Maby you can adapt it to work for you. expandcollapse popup;################################################################################################## ; ; ListVer Function ; ; Revision 0 ; Last Edited August 30, 2005 for Falcon 4 Dance Partner version 1.1 ; Written by David C. Reynolds ; ; - Creates a list menu of all compatible versions ; ; - Dependant Functions: ; [Versions.dat] ; <GUIConstants.au3> ; ErrorFunc ; ; - Input Variables: ; $title The title of the menu ; $insttext Instructional text ; $line The line in Versions.dat to start reading ; ; - Output Returns: ; $output The name of the version selected ; "0" if unsuccessful ; ;################################################################################################## ;__________________________________________________________________________________________________ ; BEGIN LISTVER FUNCTION- Func ListVer ($title, $insttext, $line) ;__________________________________________________________________________________________________ ; DECLARE LOCAL VARIABLES- ; Title of the GUI window: Local $title ; Instructional text at top of window: Local $insttext ; Line in Versions.dat file to start reading: Local $line ; Control handle for the listbox: Local $verlist ; Control handle for the Versions.dat file: Local $file ; Text of the version info read: Local $version ; Control number of the Select button: Local $select ; Control number of the Cancel button: Local $cancel ; The name of the version selected: Local $output ;__________________________________________________________________________________________________ ; GUI CREATION- ; Create the GUI window: GUICreate ($title, 400, 430) If @error = 1 Then ErrorFunc ("The Versions Interface Window failed to initialize.", "ListVer-GUICreate") EndIf ; Create instructional text: GUICtrlCreateLabel ($insttext, 25, 10, 350, 50) ;__________________________________________________________________________________________________ ; CREATE VERSION LIST- ; Create listbox: $verlist = GUICtrlCreateList ("", 25, 50, 350, 300) GUICtrlSetState (-1, $GUI_FOCUS) ; Open \Data\Versions.dat file: $file = FileOpen (@ScriptDir & "\Data\Versions.dat", 0) If $file = -1 Then ErrorFunc ("Unable to open file " & @ScriptDir & "\Data\Versions.dat", "ListVer-FileOpen") EndIf ; Create list of all versions: While 1 $version = FileReadLine ($file, $line) If @error Then ExitLoop EndIf GUICtrlSetData ($verlist, $version) $line = ($line + 5) Wend ; Close the Versions.dat file FileClose ($file) ;__________________________________________________________________________________________________ ; CREATE GUI BUTTONS- ; Create Select button: $select = GUICtrlCreateButton ("Select Version", 25, 360, 350) GUICtrlSetState (-1, $GUI_DISABLE) ; Create Cancel button: $cancel = GUICtrlCreateButton ("Cancel", 25, 385, 350) ; Show the GUI: GUISetState (@SW_SHOW) ;__________________________________________________________________________________________________ ; AWAIT USER INPUT- ; Await User Input to define action to take: While 1 $msg = GUIGetMsg () Select Case $msg = $GUI_EVENT_CLOSE GUIDelete () Return 0 Case $msg = $cancel GUIDelete () Return 0 Case (($msg = $verlist) AND (GUICtrlRead ($verlist) <> "")) GUICtrlSetState ($select, $GUI_ENABLE) Case $msg = $select $output = GUICtrlRead ($verlist) ExitLoop EndSelect Wend ;__________________________________________________________________________________________________ ; END LISTVER FUNCTION- GUIDelete () Return $output EndFunc hope it helps. Good luck! -DRX
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