RC86 Posted September 19, 2017 Posted September 19, 2017 (edited) Afternoon, I could very well be doing this wrong so feel free to totally advise otherwise - I'm wanting to use a GUI to first display a key from within an INI file, then secondly change the INI file by using a FileSelectFolder command but then I want to see the GUI change to reflect the change I've just made. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Input1 = GUICtrlCreateInput(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 121, 21) $Button1 = GUICtrlCreateButton("Change", 200, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) EndIf EndSwitch WEnd So 2 part question really: (1) Should I be using GUICtrlCreateInput to display my INI read from within the GUI? (2) How can I refresh the GUI to update that to read the new information I've just written to the GUI? Thanks! Edited September 19, 2017 by RC86 Adding screenshot of GUI when running.
Simpel Posted September 19, 2017 Posted September 19, 2017 Hi. You can use GUICtrlSetData() to set the new value. I would prefer a label rather than an input, because it wouldn't look like you can write the path with keyboard. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 615, 437, 192, 124) Local $Input1 = GUICtrlCreateLabel(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 321, 21) ; LABEL instead Input Local $Button1 = GUICtrlCreateButton("Change", 400, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $nMsg, $selectedFolder, $newLogPath While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) GUICtrlSetData($Input1, Iniread(@WorkingDir & "\test.ini","Path","FilePath","")) ; SET date into label EndIf EndSwitch WEnd Conrad RC86 1 SciTE4AutoIt = 3.7.3.0 AutoIt = 3.3.14.2 AutoItX64 = 0 OS = Win_10 Build = 19044 OSArch = X64 Language = 0407/german H:\...\AutoIt3\SciTE H:\...\AutoIt3 H:\...\AutoIt3\Include (H:\ = Network Drive) Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.
RC86 Posted September 19, 2017 Author Posted September 19, 2017 14 minutes ago, Simpel said: Hi. You can use GUICtrlSetData() to set the new value. I would prefer a label rather than an input, because it wouldn't look like you can write the path with keyboard. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 615, 437, 192, 124) Local $Input1 = GUICtrlCreateLabel(Iniread(@WorkingDir & "\test.ini","Path","FilePath",""), 64, 80, 321, 21) ; LABEL instead Input Local $Button1 = GUICtrlCreateButton("Change", 400, 80, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $nMsg, $selectedFolder, $newLogPath While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $selectedFolder = FileSelectFolder("Select Log Path Directory",@WorkingDir,0) If NOT $selectedFolder = "" Then $newLogPath = IniWrite(@WorkingDir & "\test.ini","Path","FilePath",$selectedFolder) GUICtrlSetData($Input1, Iniread(@WorkingDir & "\test.ini","Path","FilePath","")) ; SET date into label EndIf EndSwitch WEnd Conrad Awesome! That was a lot easier than expected thank you very much!
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