lopolop Posted August 12, 2006 Share Posted August 12, 2006 well i aint the greatest with using GUI and code.. so i am makeing a program with different settings that need to be specified according to what is needed for that task... but i want you to be able to select different settings through a combo box... ehhh kind of hard to explain. <Combo Box> ... Each selection is selecting a *.ini file from Program Folder... But when you select the Pre-Made *.ini it updates the settings... If you dont understand ill try to explain it better... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 12, 2006 Moderators Share Posted August 12, 2006 well i aint the greatest with using GUI and code.. so i am makeing a program with different settings that need to be specified according to what is needed for that task... but i want you to be able to select different settings through a combo box...ehhh kind of hard to explain.<Combo Box> ... Each selection is selecting a *.ini file from Program Folder...But when you select the Pre-Made *.ini it updates the settings... If you dont understand ill try to explain it better...Sounds like fun and tedious, post the code when you're done . 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 More sharing options...
lopolop Posted August 12, 2006 Author Share Posted August 12, 2006 (edited) ehh that was a question.. but after searching*sorry* i came up with this unworking code... #include <GUIConstants.au3> $Form1 = GUICreate("Test Form", 273, 409, 387, 194) GUISetBkColor(0xA6CAF0) $Group2 = GUICtrlCreateGroup("Input", 144, 8, 121, 49) GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Profile", 8, 8, 121, 49) GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Profiles = GUICtrlCreateCombo("", 16, 24, 105, 21) $Input = GUICtrlCreateInput("0000000", 152, 24, 105, 21, -1, $WS_EX_CLIENTEDGE) $Search = FileFindFirstFile(".ini") $spl = "|" GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) While 1 $spl = $spl & FileFindNextFile($search) & "|" If @error Then ExitLoop WEnd $filearray=StringSplit($spl,"|") GUICtrlSetData($Profiles,$spl,$filearray[2]) FileClose($search) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit gives me a blank selection for me to choose from combo Edited August 12, 2006 by lopolop Link to comment Share on other sites More sharing options...
Valuater Posted August 12, 2006 Share Posted August 12, 2006 (edited) $Search = FileFindFirstFile("*.ini") will do the trick 8) Edited August 12, 2006 by Valuater Link to comment Share on other sites More sharing options...
lopolop Posted August 12, 2006 Author Share Posted August 12, 2006 yes thank you! but now i got the second thing i was asking before... how can i do this that when i select the *.ini that the Input will change to what is in the ini file.. so something like this... expandcollapse popup#include <GUIConstants.au3> $inp = "0000000" $Form1 = GUICreate("Test Form", 273, 409, 387, 194) GUISetBkColor(0xA6CAF0) $Group2 = GUICtrlCreateGroup("Input", 144, 8, 121, 49) GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Profile", 8, 8, 121, 49) GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Profiles = GUICtrlCreateCombo("", 16, 24, 105, 21) $Input = GUICtrlCreateInput($inp, 152, 24, 105, 21, -1, $WS_EX_CLIENTEDGE) $Search = FileFindFirstFile("*.ini") $spl = "|" GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) While 1 $spl = $spl & FileFindNextFile($search) & "|" If @error Then ExitLoop WEnd $filearray=StringSplit($spl,"|") GUICtrlSetData($Profiles,$spl,$filearray[2]) FileClose($search) $file = GUICtrlRead($Profiles) $inp = IniRead($file, "Settings", "Input", "default") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit This didnt work but i see why just dont know how to make it $inp like Refresh.. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 12, 2006 Moderators Share Posted August 12, 2006 Read it all with the ini functions and guictrlsetdata() 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 More sharing options...
lopolop Posted August 12, 2006 Author Share Posted August 12, 2006 what do you mean read it all? i tried this: expandcollapse popup#include <GUIConstants.au3> $inp = "0000000" $Form1 = GUICreate("Test Form", 273, 409, 387, 194) GUISetBkColor(0xA6CAF0) $Group2 = GUICtrlCreateGroup("Input", 144, 8, 121, 49) GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group1 = GUICtrlCreateGroup("Profile", 8, 8, 121, 49) GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Profiles = GUICtrlCreateCombo("", 16, 24, 105, 21) $Input = GUICtrlCreateInput($inp, 152, 24, 105, 21, -1, $WS_EX_CLIENTEDGE) $Search = FileFindFirstFile("*.ini") $spl = "|" GUICtrlSetBkColor(-1, 0xA6CAF0) GUICtrlCreateGroup("", -99, -99, 1, 1) While 1 $spl = $spl & FileFindNextFile($search) & "|" If @error Then ExitLoop WEnd $filearray=StringSplit($spl,"|") GUICtrlSetData($Profiles,$spl,$filearray[2]) FileClose($search) $file = GUICtrlRead($Profiles) $inp = IniRead($file, "Settings", "Input", "default") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() GUICtrlSetData($Input, $inp) Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit that semi-worked because it did change the Value from 00000 to the first file that was selected in the combo box but.. when i change the combo box to a different *.ini file it Wont "Refresh" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 12, 2006 Moderators Share Posted August 12, 2006 do IniReadSection() ... parse the array into the info you want, and go from there with GUICtrlSetData() 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 More sharing options...
lopolop Posted August 12, 2006 Author Share Posted August 12, 2006 (edited) what do you mean by parse... i change $inp and GuiCtrlSetData to this but it still didnt work... $inp = IniReadSection($file, "Settings") GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() for $i = 1 to $inp[0][0] GUICtrlSetData($Input, $inp[$i][1]) Next Well if this cant really work i guess i could just have a load button which would always work. Thanks for the help! Edited August 12, 2006 by lopolop Link to comment Share on other sites More sharing options...
Zib Posted August 12, 2006 Share Posted August 12, 2006 (edited) My solution. expandcollapse popup#include <GUIConstants.au3> #Include <Array.au3> $Form1 = GUICreate("Test Form", 273, 209, 387, 194) GUICtrlCreateGroup("Input", 144, 8, 121, 49) GUICtrlCreateGroup("Profile", 8, 8, 121, 49) $Profiles = GUICtrlCreateCombo("", 16, 24, 105, 21) $Input = GUICtrlCreateInput("", 152, 24, 105, 21, -1, $WS_EX_CLIENTEDGE) $Search = FileFindFirstFile(@ScriptDir & "\" & "*.ini") $ProfileArray = _ArrayCreate($Search) While 1 $File = FileFindNextFile($Search) If @error Then ExitLoop _ArrayAdd($ProfileArray, $File) WEnd FileClose($Search) For $r = 1 To UBound($ProfileArray, 1) - 1 GUICtrlSetData($Profiles, StringTrimRight($ProfileArray[$r], 4)) Next $Current_Profile = GUICtrlRead($Profiles) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case GUICtrlRead($Profiles) <> $Current_Profile GUICtrlSetData($Input, IniRead(GUICtrlRead($Profiles)&".ini", "Settings", "Input", "default")) $Current_Profile = GUICtrlRead($Profiles) Case Else ;;;;;;; EndSelect WEnd Exit Edited August 12, 2006 by Zib Link to comment Share on other sites More sharing options...
lopolop Posted August 13, 2006 Author Share Posted August 13, 2006 wow thanks alot! works perfectly Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 13, 2006 Moderators Share Posted August 13, 2006 This thread gave me an idea to populate through an Ini if I wanted to go through each value in a GUI.... Just change MyIni.ini to whatever... not really what your looking for here, but I think I'll find a use for it. expandcollapse popup#include <guiconstants.au3> Opt('GUIOnEventMode', 1) Global $IniInfo = _IniGetSKV(@DesktopDir & '\MyIni.ini') Global $IniSect, $IniKey, $IniValue $MainGUI = GUICreate('Example', 200, 100) $Combo = GUICtrlCreateCombo('', 10, 10, 180, 150) $Input = GUICtrlCreateInput('', 10, 35, 180, 20, $ES_CENTER) For $i = 1 To UBound($IniInfo, 1) - 1 $IniSect &= $IniInfo[$i][$i][0] & '|' Next GUICtrlSetData($Combo, $IniSect) GUICtrlSetOnEvent($Combo, '_CheckIniStat') GUISetOnEvent($GUI_EVENT_CLOSE, '_ExitNow', $MainGUI) GUISetState() While 1 Sleep(1000) WEnd Func _CheckIniStat() Local $sString = GUICtrlRead($Combo), $iFound Local $iCount, $ixCount, $xCount, $sHold For $ixCount = 1 To UBound($IniInfo, 1) - 1 For $iCount = 1 To UBound($IniInfo, 2) - 1 If $sString = $IniInfo[$ixCount][$iCount][0] Then For $xCount = 1 To UBound($IniInfo, 2) - 1 $sHold &= $IniInfo[$ixCount][$xCount][1] & '|' Next $iFound = 1 ExitLoop ElseIf $sString = $IniInfo[$ixCount][$iCount][1] Then $sHold &= $IniInfo[$ixCount][$iCount][2] & '|' $iFound = 1 ExitLoop ElseIf $sString = $IniInfo[$ixCount][$iCount][2] Then GUICtrlSetData($Input, $sString) GUICtrlSetData($Combo, '') GUICtrlSetData($Combo, StringTrimRight($IniSect, 1)) $iFound = 3 ExitLoop EndIf Next If $iFound Then ExitLoop Next If Not $iFound Then Return SetError(1, 0, 0) If $iFound <> 3 Then GUICtrlSetData($Combo, '') GUICtrlSetData($Combo, $sString & '|' & StringTrimRight($sHold, 1), $sString) EndIf EndFunc Func _ExitNow() Exit EndFunc Func _IniGetSKV($hIniLocation) ;Get All Sections Local $aSections = IniReadSectionNames($hIniLocation) If @error Then Return SetError(1, 0, 0) ;Get All The Keys and Values for Each section Local $aKeyValues[$aSections[0]+1][1][3] For $iCount = 1 To $aSections[0] $aKV = IniReadSection($hIniLocation, $aSections[$iCount]) ReDim $aKeyValues[$aSections[0]+1][$aKV[0][0]+1][3] For $xCount = 1 To $aKV[0][0] $aKeyValues[$iCount][$xCount][0] = $aSections[$iCount] $aKeyValues[$iCount][$xCount][1] = $aKV[$xCount][0] $aKeyValues[$iCount][$xCount][2] = $aKV[$xCount][1] Next Next Return $aKeyValues ;Return a 3 Dimensional Array EndFuncIt's not cleaned up, but it works. 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 More sharing options...
lopolop Posted August 13, 2006 Author Share Posted August 13, 2006 (edited) ok i got two more problems or well maybe just questions... But first thing, i have check Boxes that need to be changed according to profile, but i cant seem to find a way to make them change i tried(setting ini to have $GUI_Checked) and doing this at the end of Zib's code GUICtrlSetState($test, IniRead(GUICtrlRead($Profiles)&".ini", "Settings", "test", "default")) ;And $testState = IniRead(GUICtrlRead($Profiles)&".ini", "Settings", "test", "default") GUICtrlSetState($test, $testState) but no luck.. Also for the second thing i would like to know the best way to call the data.. should it be done directly from the ini? or should i just use GuiCtrlRead()? Edited August 13, 2006 by lopolop 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