Jump to content

Iniwrite from input field


Kaelin
 Share

Recommended Posts

Hello, I am fairly new to AutoIT and I am only just getting used to coding with it. So far it is fantastic, but I have hit a wall and can't seem to find a work around.

I am attempting to write a dialog that will read from an .ini file and display the information in text fields. This part I have down. The problem I have now is when I try to write the information back into the ini file I do not get the desired information, but numbers instead.

My code (sorry its messy...):

; Script Start
; Define Variables
#cs /////////////////////////
    //Server Configuration //
#ce /////////////////////////

$sIni = "test.ini"

$rinigroupname = IniRead("server.ini","SERVER CONFIGURATION","GROUPNAME","Not Found")
$rinigroupnumber = IniRead("server.ini","SERVER CONFIGURATION","GROUPNO","Not Found")
$riniservername = IniRead("server.ini","SERVER CONFIGURATION","SERVERNAME","Not Found")
$rinigameservernumber = IniRead("server.ini","SERVER CONFIGURATION","GAMESERVERNO","Not Found")

$rinicreatelog = IniRead("server.ini","SERVER CONFIGURATION","CREATEGAMELOG","Not Found")
$rinicreatedebug = IniRead("server.ini","SERVER CONFIGURATION","CREATEGAMEDEBUG","Not Found")
$rinigamesynctime = IniRead("server.ini","SERVER CONFIGURATION","GAMESYNCTIME","Not Found")
$rinilanguage = IniRead("server.ini","SERVER CONFIGURATION","LANGUAGE","Not Found")
$rinitestserver = IniRead("server.ini","SERVER CONFIGURATION","TESTSERVER","Not Found")
$riniresenttime = IniRead("server.ini","SERVER CONFIGURATION","RESENTTIME","Not Found")
$riniahnlab = IniRead("server.ini","SERVER CONFIGURATION","AHNLAB","Not Found")

;World
$riniworldno = IniRead("server.ini","SERVER CONFIGURATION","SERVICEWORLDNO","Not Found")
$riniworldlist = IniRead("server.ini","SERVER CONFIGURATION","SERVICEWORLDLIST","Not Found")
$rinipkworldno = IniRead("server.ini","SERVER CONFIGURATION","SERVICEPKWORLDNO","Not Found")
$rinipkworldlist = IniRead("server.ini","SERVER CONFIGURATION","SERVICEPKWORLDLIST","Not Found")

#cs /////////////
    // Network //
#ce /////////////

$riniserviceip = IniRead("server.ini","NETWORK","SERVICEIP","Not Found")
$riniserviceport = IniRead("server.ini","NETWORK","SERVICEPORT","Not Found")
$rinilocalip = IniRead("server.ini","NETWORK","LOCALIP","Not Found")
$rinilocalport = IniRead("server.ini","NETWORK","LOCALPORT","Not Found")
$rinimasterip = IniRead("server.ini","NETWORK","MASTERSERVERIP","Not Found")
$rinimasterport = IniRead("server.ini","NETWORK","MASTERSERVERPORT","Not Found")
$rinimanager = IniRead("server.ini","NETWORK","ISMANAGER","Not Found")
$rinimanagerip = IniRead("server.ini","NETWORK","MANAGERSERVERIP","Not Found")
$rinimanagerport = IniRead("server.ini","NETWORK","MANAGERSERVERPORT","Not Found")



#cs
Form Start
#ce

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)


#Region ### START Koda GUI section ### Form=C:\Users\Kaelin\Desktop\Dialog.kxf
$Dialog = GUICreate("Server Configuration", 431, 329, 192, 123, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS,$DS_CONTEXTHELP))
GUISetOnEvent($GUI_EVENT_CLOSE, "DialogClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "DialogMinimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "DialogMaximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "DialogRestore")
$GS1config = GUICtrlCreateTab(0, 0, 433, 281)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("Configuration")
$Group2 = GUICtrlCreateGroup("Server Configuration", 7, 29, 409, 241)
$ServerGroupName = GUICtrlCreateLabel("Server Group Name:", 19, 54, 118, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "ServerGroupNameClick")
$ServerGroupName_u = GUICtrlCreateInput($rinigroupname, 163, 52, 193, 21)
GUICtrlSetOnEvent(-1, "ServerGroupName_uChange")
$ServerGroupNumber = GUICtrlCreateLabel("Server Group Number:", 19, 77, 130, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "ServerGroupNumberClick")
$ServerGroupNumber_u = GUICtrlCreateInput($rinigroupnumber, 163, 76, 193, 21)
GUICtrlSetOnEvent(-1, "ServerGroupNumber_uChange")
$ServerName = GUICtrlCreateLabel("Server Name:", 19, 101, 81, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "ServerNameClick")
$ServerName_u = GUICtrlCreateInput($riniservername, 163, 100, 193, 21)
GUICtrlSetOnEvent(-1, "ServerName_uChange")
$TotalWorldNumber = GUICtrlCreateLabel("Total World Number:", 20, 169, 120, 15)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "TotalWorldNumberClick")
$GameServerNumber = GUICtrlCreateLabel("Game Server Number:", 20, 125, 129, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "GameServerNumberClick")
$GameServerNumber_u = GUICtrlCreateInput($rinigameservernumber, 163, 124, 193, 21)
GUICtrlSetOnEvent(-1, "GameServerNumber_uChange")
$TotalWorldNumber_u = GUICtrlCreateInput($riniworldno, 163, 167, 193, 21)
GUICtrlSetOnEvent(-1, "TotalWorldNumber_uChange")
$MapsToLoad = GUICtrlCreateLabel("Maps To Load:", 21, 193, 86, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "MapsToLoadClick")
$MapsToLoad_u = GUICtrlCreateInput($riniworldlist, 163, 191, 193, 21)
GUICtrlSetOnEvent(-1, "MapsToLoad_uChange")
$PKMapsToLoad_u = GUICtrlCreateInput($rinipkworldlist, 163, 239, 193, 21)
GUICtrlSetOnEvent(-1, "PKMapsToLoad_uChange")
$PKMapsToLoad = GUICtrlCreateLabel("Maps To Load:", 21, 241, 86, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "PKMapsToLoadClick")
$TotalPKWorldNumber = GUICtrlCreateLabel("Total PK World Number:", 21, 217, 139, 19)
GUICtrlSetFont(-1, 9, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetOnEvent(-1, "TotalPKWorldNumberClick")
$TotalPKWorldNumber_u = GUICtrlCreateInput($rinipkworldno, 163, 215, 193, 21)
GUICtrlSetOnEvent(-1, "TotalPKWorldNumber_uChange")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet2 = GUICtrlCreateTabItem("Network Settings")
$TabSheet3 = GUICtrlCreateTabItem("Logic")
GUICtrlCreateTabItem("")
GUICtrlSetOnEvent(-1, "GS1configChange")
$btn_write = GUICtrlCreateButton("Write Settings", 32, 288, 137, 33, $WS_GROUP)
GUICtrlSetOnEvent(-1, "btn_writeClick")
$btn_cancel = GUICtrlCreateButton("Cancel", 264, 288, 129, 33, $WS_GROUP)
GUICtrlSetOnEvent(-1, "btn_cancelClick")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func btn_cancelClick()
$varclose = MsgBox(4,"Dialog","Are you sure you want to exit?")
If $varclose = 6 Then Exit
EndFunc

Func btn_writeClick()
$varwrite = MsgBox(4,"Dialog","Are you sure you want to write current settings?")
    If $varwrite = 6 Then

#cs //////////////////////////////
    // Ini Write Section Define //
#ce //////////////////////////////
$sData = "GROUPNAME=        " & $ServerGroupName_u & @LF & "GROUPNO=        " & $ServerGroupNumber_u & @LF & "SERVERNAME=       " & $ServerName_u & @LF & "GAMESERVERNO=        " & $GameServerNumber_u & @LF & "SERVICEWORLDNO=        " & $TotalWorldNumber_u & @LF & "SERVICEWORLDLIST=  " & $MapsToLoad_u & @LF & "SERVICEPKWORLDNO=    " & $TotalPKWorldNumber_u & @LF & "SERVICEPKWORLDLIST=  " & $PKMapsToLoad_u & @LF
IniWriteSection($sIni, "SERVER CONFIGURATION", $sData)

    ;IniWriteSection($sIni, "NETWORK", $sData1) ; Write to a new section.

    EndIf
EndFunc

Func DialogClose()
$varclose = MsgBox(4,"Dialog","Are you sure you want to exit?")
If $varclose = 6 Then Exit
EndFunc
Func DialogMaximize()

EndFunc
Func DialogMinimize()

EndFunc
Func DialogRestore()

EndFunc
Func GameServerNumber_uChange()

EndFunc
Func GameServerNumberClick()

EndFunc
Func GS1configChange()

EndFunc
Func MapsToLoad_uChange()

EndFunc
Func MapsToLoadClick()

EndFunc
Func PKMapsToLoad_uChange()

EndFunc
Func PKMapsToLoadClick()

EndFunc
Func ServerGroupName_uChange()

EndFunc
Func ServerGroupNameClick()

EndFunc
Func ServerGroupNumber_uChange()

EndFunc
Func ServerGroupNumberClick()

EndFunc
Func ServerName_uChange()

EndFunc
Func ServerNameClick()

EndFunc
Func TotalPKWorldNumber_uChange()

EndFunc
Func TotalPKWorldNumberClick()

EndFunc
Func TotalWorldNumber_uChange()

EndFunc
Func TotalWorldNumberClick()

EndFunc

And this is the ini...

[SERVER CONFIGURATION]
GROUPNAME=      Aeon
GROUPNO=        1
SERVERNAME=     G1_Manager
GAMESERVERNO=       0

SERVICEWORLDNO=     10
SERVICEWORLDLIST=   0 1 2 3 4 5 6 7 8 9
SERVICEPKWORLDNO=   0
SERVICEPKWORLDLIST= 99

:) Any help is most appreciated!

Link to comment
Share on other sites

That's easy :)

What you now write to the ini-file is the ControlId of the GUI input fields. You have to access the VALUE of the input fields like:

$sServerGroupNumber = GUICtrlRead($ServerGroupNumber_u)
Then you can write $sServerGroupNumber to the ini file. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

  • Recently Browsing   0 members

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