Jump to content

Ini read/write.


Recommended Posts

I got a script that settings from an ini file - it does this fine.

Then I have a GUI displaying some information from this ini - fine.

You then edit the input boxes and click login, at this point it should be rewriting the ini file with new information - I'm nor sure what goes wrong here

Now when i next open it, the fields are 4, 6, 8, 10 and 12 - not text strings.

Really, I don't understand what I'm doing wrong.

Please help me!

#include <GUIConstants.au3>
$iniuser=IniRead("settings.ini", "login", "username", "Login")
$inipass=IniRead("settings.ini", "login", "password", "Password")
$inichar=IniRead("settings.ini", "login", "character", "1")
$inipath=IniRead("settings.ini", "paths", "sropath", "C:\Program Files\Silkroad")
$inibot=IniRead("settings.ini", "paths", "botpath", "C:\Program Files\bot")
Opt("GUIOnEventMode", 1)
$window=GUICreate("Login", 216,128) 
GUICtrlCreateLabel("Login:",5,7,30,20)
$login=GUICtrlCreateInput($iniuser,70,5,85,20,-1)
GUICtrlCreateLabel("Password:",5,34,50,20)
$password=GUICtrlCreateInput($inipass, 70,30,85 , 20,-1)
GUICtrlCreateLabel("Char Nr:",5,58,50,20)
$character=GUICtrlCreateInput($inichar,70,55,20,20,-1)
GUICtrlCreateLabel("Silkroad Dir:",5,84,60,20)
$sropath=GUICtrlCreateInput($inipath,70,80,142,20,-1)
GUICtrlCreateLabel("Silkroad Dir:",5, 109,60,20)
$botpath=GUICtrlCreateInput($inibot,70,105,142,20,-1)
$okbutton=GUICtrlCreateButton("Login",170,10,40)
GUICtrlSetOnEvent($okbutton,"OKButton")
$exitbutton=GUICtrlCreateButton("Exit",170,42,40)
GUICtrlSetOnEvent($exitbutton,"EXITButton")
GUISetOnEvent($GUI_EVENT_CLOSE,"CLOSEClicked")

GUISetState(@SW_SHOW)
While 1
Sleep(50)
WEnd

Func OKButton()
    IniWrite("settings.ini", "login", "username", $login)
    Iniwrite("settings.ini", "login", "password", $password)
    Iniwrite("settings.ini", "login", "character", $character)
    Iniwrite("settings.ini", "paths", "sropath", $sropath)
    Iniwrite("settings.ini", "paths", "botpath", $botpath)
EndFunc

Func EXITButton()
    MsgBox("","Goodbye", "Thank you for using my login script.",3)
    Exit
EndFunc

Func CLOSEClicked()
    Exit
EndFunc
Link to comment
Share on other sites

#include <GUIConstants.au3>
$iniuser=IniRead("settings.ini", "login", "username", "Login")
$inipass=IniRead("settings.ini", "login", "password", "Password")
$inichar=IniRead("settings.ini", "login", "character", "1")
$inipath=IniRead("settings.ini", "paths", "sropath", "C:\Program Files\Silkroad")
$inibot=IniRead("settings.ini", "paths", "botpath", "C:\Program Files\bot")
Opt("GUIOnEventMode", 1)
$window=GUICreate("Login", 216,128)
GUICtrlCreateLabel("Login:",5,7,30,20)
$login=GUICtrlCreateInput($iniuser,70,5,85,20,-1)
GUICtrlCreateLabel("Password:",5,34,50,20)
$password=GUICtrlCreateInput($inipass, 70,30,85 , 20,-1)
GUICtrlCreateLabel("Char Nr:",5,58,50,20)
$character=GUICtrlCreateInput($inichar,70,55,20,20,-1)
GUICtrlCreateLabel("Silkroad Dir:",5,84,60,20)
$sropath=GUICtrlCreateInput($inipath,70,80,142,20,-1)
GUICtrlCreateLabel("Silkroad Dir:",5, 109,60,20)
$botpath=GUICtrlCreateInput($inibot,70,105,142,20,-1)
$okbutton=GUICtrlCreateButton("Login",170,10,40)
GUICtrlSetOnEvent($okbutton,"OKButton")
$exitbutton=GUICtrlCreateButton("Exit",170,42,40)
GUICtrlSetOnEvent($exitbutton,"EXITButton")
GUISetOnEvent($GUI_EVENT_CLOSE,"CLOSEClicked")

GUISetState(@SW_SHOW)
While 1
Sleep(50)
WEnd

Func OKButton()
    IniWrite("settings.ini", "login", "username", GUICtrlRead($login))
    Iniwrite("settings.ini", "login", "password", GUICtrlRead($password))
    Iniwrite("settings.ini", "login", "character", GUICtrlRead($character))
    Iniwrite("settings.ini", "paths", "sropath", GUICtrlRead($sropath))
    Iniwrite("settings.ini", "paths", "botpath", GUICtrlRead($botpath))
EndFunc

Func EXITButton()
    MsgBox("","Goodbye", "Thank you for using my login script.",3)
    Exit
EndFunc

Func CLOSEClicked()
    Exit
EndFunc

Use it like that, when you create controls, the controls handle is returned. It is simply a number. You have to use the GUICtrlRead function to actually read the data that is in the control.

EDIT:

It seems all three of us read the page and started posting at around the same time. :P

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

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...