Jump to content

settings app


Recommended Posts

Hi there,

I recently started using autoit so it is currently a little hard wrapping my brain around it.

But what I need autoit to is to replace or rather change some text in a file.

The situation is that I have a settings file that is structured like this

[Configuration]

Server=127.0.0.1

WebHost=auto

Nickname=Whatever

And I would like to have an application that changes the server setting to another ip without having to edit it in notepad

I found something that has a similar purpose and it is a realmlist changer for world of warcraft.

my problem is that I cant figure out how to change it so it fits my needs.

p.s. Sorry if my English isnt top notch, it is my second language

Here be lyin´ code

#include <GUIConstants.au3>
#include <ComboConstants.au3>
GUICreate("Realmlist", 400,400,100,100)
$open=FileOpen ( "C:\Program Files\World of Warcraft\realmlist.wtf", 0 )
$realm = FileReadLine($open,1)
$mylist=GUICtrlCreateList ("", 75,200,250,97)
GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling
GUICtrlSetData(-1,$realm)
GUICtrlCreateLabel("current realms",85,180)
$realms=GUICtrlCreateCombo ("", 10,10,250) ; create first item
$button1 = GuiCtrlCreateButton("Set Realm", 30, 90, 130, 20)
$var = IniReadSection("realm.ini", "realms")
If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
Select 
Case $var[0][0]=1
GUICtrlSetData($realms,$var[1][1])
Case $var[0][0]=2 
GUICtrlSetData($realms,$var[1][1])
GUICtrlSetData($realms,$var[2][1])
Case $var[0][0]=3 
GUICtrlSetData($realms,$var[1][1])
GUICtrlSetData($realms,$var[2][1])
GUICtrlSetData($realms,$var[3][1])
Case $var[0][0]=4 
GUICtrlSetData($realms,$var[1][1])
GUICtrlSetData($realms,$var[2][1])
GUICtrlSetData($realms,$var[3][1])
GUICtrlSetData($realms,$var[4][1])
Case $var[0][0]=5 
GUICtrlSetData($realms,$var[1][1])
GUICtrlSetData($realms,$var[2][1])
GUICtrlSetData($realms,$var[3][1])
GUICtrlSetData($realms,$var[4][1])
GUICtrlSetData($realms,$var[5][1])
Case $var[0][0]>5 
    MsgBox(4096, "", "teveel realms")
EndSelect
EndIf


GUISetState ()
$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $button1
$selected=GUICtrlRead($realms)
$file=FileOpen ( "C:\Program Files\World of Warcraft\realmlist.wtf", 2 )
FileWrite($file, $selected)
GUICtrlSetData($mylist,"")
GUICtrlSetData($mylist,$selected)   
EndSelect
WEnd
FileClose($open)
Link to comment
Share on other sites

Just read about Ini Files in the help file then start your code all over. Pay particular attention to the IniReadSection() IniRerad() and IniWrite() functions.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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