M4M Posted October 29, 2006 Posted October 29, 2006 I am working on a script and I am tring to figure out how to re-load a gui. To help explain my problem, here is an example (note, all gui stuff is in one script): begining of script: GUI1 this is the gui that gets loaded first. think of it as a font-end (sellect an option and run it, like notepad.exe, cmd.exe, nero.exe, ect). GUI2 this is a gui that allows you to make/save changes in the ini file that holds settings such as app name, exe location, ect. end of script: How can I script it so that if I make a change in GUI2 (and save it), the changes are immediatly shown in GUI1? I am sure it involves reloading the first gui, but I am not sure how to do it without completely closing out the script and restarting it.
_Kurt Posted October 30, 2006 Posted October 30, 2006 (edited) Okay, I think I understand what you're trying to say This is a function that would read the selection the user made, and once he presses OK (from GUI 2) it will automatically re-load GUI 1 with the configured settings (note that GUI 1 must have somewhere to show the settings and any sort of readable folder (i.e. INI folder), obviously ). Func Example() $Select = GUICtrlRead($Selection);Reads the selection If $Select = "" Then Return;If the selection is the same as the previous set settings than do nothing FileDelete(@ScriptDir & "\Settings.ini");Delete the Settings.ini (to be re-written) FileWrite(@ScriptDir & "\Settings.ini", "test" & $Select);Re-write the settings with the new adjustments Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath));Re-run the original application (to get GUI 1) Exit EndFunc Hopefully I understood you correctly and helped you out a little Edited October 30, 2006 by _Kurt Awaiting Diablo III..
M4M Posted October 30, 2006 Author Posted October 30, 2006 (edited) lol, yea, I worded it very poorly, and I apologise for that. your idea is good, but deleting the ini file would kinda kill the point for the "app" that I am creating..... and it is more or less a front-end for daemon tools. The ini file would hold such info as: cd image location, daemon tools exe location, ect, ect. ....I kinda wanted to keep my idea under wraps until I was happy with the finished product, but I suppose in order for others to better help me, I need to give up some info, lol. So, now that you know what I am after, let my try to word it a little more properly... Still running from one script... GUI1: Main GUI. User sellect a game from the drop-down list to run, along with buttons such as: run, edit/delete/add game, options, and exit. GUI2: Settings GUI. This GUI gives you the options to add/edit/delete a game from the INI file, sellect where the ISO is located, auto-run screen name, exe file location, ect.. What it currently does: If a person clicks on the add/edit/delete button, the main gui drops to the task bar (will explain why later) and the edit gui opens up. Once the changes are made, and the user clicks on save, the settings are saved to an ini file, then the user needs to click on close (this is done to prevent lose of changes made), and then the options gui closes and the main gui comes back up. Why it works the way it does (main gui dropping to taskbar): I tried closing the main gui, loading the options gui, and when that is closed, the script would return to the top, thus re-launching the main gui. BUT, apon doing this, the script either 1: had an error that I could not find/fix or 2: would not re-load the settings in the settings.ini file. Edited October 30, 2006 by M4M
M4M Posted October 30, 2006 Author Posted October 30, 2006 heh...It was right in front of me.... Here is an example for those interested.... expandcollapse popup#include <GUIConstants.au3> #include <array.au3> GUI1() Func GUI1() $Form1 = GUICreate("AForm1", 633, 447, 193, 115) $Combo1 = GUICtrlCreateCombo("ACombo1", 56, 32, 385, 25) $Button1 = GUICtrlCreateButton("Close", 56, 64, 177, 49, 0) $Button2 = GUICtrlCreateButton("Edit", 248, 64, 193, 49, 0) $GameListData = IniReadSectionNames("Setting.ini") If @error Then MsgBox(16,"setting.ini file missing/empty!","Your setting.ini file is missing/empty! One will be created/filled for you for this test") IniWrite("setting.ini","List one","","") IniWrite("setting.ini","List two","","") IniWrite("setting.ini","List three","","") GUI1() EndIf For $i = 1 To $GameListData[0] _ArraySort($GameListData) GUICtrlSetData($Combo1, $GameListData[$i]) Next GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE MsgBox(0,"Deleting ini file","When you close this, the INI file created for this test will be deleted") FileDelete("setting.ini") Exit Case $Msg = $Button2 GUIDelete("AForm1") GUI2() Exit Case $Msg = $Button1 MsgBox(0,"Deleting ini file","When you close this, the INI file created for this test will be deleted") FileDelete("setting.ini") Exit EndSelect WEnd EndFunc ; <--End of GUI1 GUI2() Func GUI2() $Form1 = GUICreate("AForm2", 550, 300, 193, 115) $Combo1 = GUICtrlCreateCombo("ACombo1", 88, 48, 409, 25) $Button1 = GUICtrlCreateButton("Done", 88, 96, 185, 33, 0) $Button2 = GUICtrlCreateButton("Delete", 296, 96, 201, 33, 0) $GameListData = IniReadSectionNames("Setting.ini") For $i = 1 To $GameListData[0] _ArraySort($GameListData) GUICtrlSetData($Combo1, $GameListData[$i]) Next GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $Button1 GUIDelete("AForm2") GUI1() Exit Case $Msg = $Button2 $test1 = GUICtrlRead($Combo1) IniDelete("setting.ini",$test1) GUIDelete("Aform2") GUI1() Exit EndSelect WEnd EndFunc ; <--End of GUI2 test.au3
_Kurt Posted October 30, 2006 Posted October 30, 2006 Okay, I'm glad you fixed your problem. If you have any more questions, just ask Awaiting Diablo III..
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