Jump to content

Recommended Posts

Posted

I've made a simple GUI below and can read from info.txt and write the default values into the input boxes at GUI startup. What I can't get to happen is to have new values read from the input boxes and written to the info.txt file. For some reason, no matter what value I put into the 3 input boxes I get integer results in info.txt and the test msgbox.

#Include <Misc.au3>
#Include <File.au3>
#Include <String.au3>
#include <GuiConstantsEx.au3>

;Check to see if the Info.txt file exists.  If not, ask to create it
$InfoFile = FileExists("C:\Info.txt")
If $InfoFile = 0 Then
    $FileCreate = MsgBox(1,"Error - Missing file","The file C:\Info.txt was not found." & @CRLF & "Click OK to create this file now and continue setup or Cancel to quit the program")
    If $FileCreate = 1 Then
        SplashTextOn("Create missing file","Creating C:\Info.txt",250,50)
        FileWriteLine("C:\Info.txt","Server not yet set" & @CRLF & "Login name not yet set" & @CRLF & "Password not yet set")
        Sleep(1000)
        SplashOff()
    Else
        Exit
    EndIf
EndIf

; Set values for account info by reading from C:\Info.txt
$Server = FileReadLine("C:\Info.txt",1)
$LoginName = FileReadLine("C:\Info.txt",2)
$LoginPswd = FileReadLine("C:\Info.txt",3)

; GUI form
GuiCreate("Account Info", 400, 200)

; GUI Labels and Input boxes
GuiCtrlCreateLabel("Enter the requested account information below", 25, 5, 400, 25)

GuiCtrlCreateLabel("Server name:", 25, 25, 75, 25)
$Input1 = GuiCtrlCreateInput($Server, 100, 23, 125, 25)

GuiCtrlCreateLabel("Account login:", 25, 50, 75, 25)
$Input2 = GuiCtrlCreateInput($LoginName, 100, 48, 126)

GuiCtrlCreateLabel("Account pswd:", 25, 75, 75, 25)
GuiCtrlCreateLabel("==>", 250, 75, 20, 25)
$Input3 = GuiCtrlCreateInput($LoginPswd, 100, 73, 125, 25)

; Gui Buttons
$BtnOK = GuiCtrlCreateButton("OK", 75, 150, 75, 25)
$BtnExit = GuiCtrlCreateButton("Exit", 250, 150, 75, 25)
$BtnReadMe = GuiCtrlCreateButton("ReadMe", 290, 70, 75, 25)

; GUI show
GuiSetState(@SW_SHOW)

; GUI Message Loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then 
        ExitLoop
    ElseIf $msg = $BtnOK Then
        GUICtrlRead($Input1)
        GUICtrlRead($Input2)
        GUICtrlRead($Input2)
        MsgBox(0,"",$Input1 & " " & $Input2 & " " & $Input3)
        $File = FileOpen("C:\Info.txt",2);Opens Info.txt and erases the existing content
        FileClose($File)
        FileWrite("C:\Info.txt",$Input1 & @CRLF & $Input2 & @CRLF & $Input3)
        ExitLoop
    ElseIf $msg = $BtnExit Then
        Exit
    ElseIf $msg = $BtnReadMe Then
        MsgBox(0,"","You need to enter the info asked for")
    EndIf            
WEnd

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...