Jump to content

Refresh GUI after ini write


RC86
 Share

Recommended Posts

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!

Capture.PNG

Edited by RC86
Adding screenshot of GUI when running.
Link to comment
Share on other sites

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

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)

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...